string_cli.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import sys
  2. import commands
  3. if __name__ == '__main__':
  4. if len(sys.argv) < 3:
  5. print('Usage: python string_cli.py <command> <string>')
  6. sys.exit(1)
  7. command = sys.argv[1]
  8. input_string = sys.argv[2]
  9. if command == 'reverse':
  10. from commands.reverse import reverse_string
  11. print(reverse_string(input_string))
  12. elif command == 'uppercase':
  13. from commands.uppercase import to_uppercase
  14. print(to_uppercase(input_string))
  15. elif command == 'lowercase':
  16. from commands.lowercase import to_lowercase
  17. print(to_lowercase(input_string))
  18. elif command == 'spongebob':
  19. from commands.spongebob import spongebob_case
  20. print(spongebob_case(input_string))
  21. elif command == 'length':
  22. from commands.length import string_length
  23. print(string_length(input_string))
  24. elif command == 'scramble':
  25. from commands.scramble import scramble_string
  26. print(scramble_string(input_string))
  27. else:
  28. print('Invalid command!')