diff options
author | AL-LCL <alvin@alvinhavel.com> | 2023-05-19 11:01:49 +0200 |
---|---|---|
committer | AL-LCL <alvin@alvinhavel.com> | 2023-05-19 11:01:49 +0200 |
commit | 20dbeb2f38684c65ff0a4b99012c161295708e88 (patch) | |
tree | a5b8445f55da2fbbb92443b68e9d7354a290c598 /domestic/parse/command_argument_parser.py |
Diffstat (limited to 'domestic/parse/command_argument_parser.py')
-rw-r--r-- | domestic/parse/command_argument_parser.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/domestic/parse/command_argument_parser.py b/domestic/parse/command_argument_parser.py new file mode 100644 index 0000000..9358d76 --- /dev/null +++ b/domestic/parse/command_argument_parser.py @@ -0,0 +1,21 @@ +def command_argument_parser(message): + arguments = message.split('--') + first = arguments[0] + + if first.endswith(' '): + first = first[:-1] + + arguments_dict = {'message': first} + + for argument in arguments[1:]: + key_value_list = [y for y in argument.split(' ') if y != ''] + + key = key_value_list[0] + value = key_value_list[1:] + + if len(key_value_list) == 1: + arguments_dict[key] = True + else: + arguments_dict[key] = ' '.join(value) + + return arguments_dict
\ No newline at end of file |