summaryrefslogtreecommitdiff
path: root/domestic/parse/command_argument_parser.py
blob: 9358d763caa00a7622a75ad141184f7648925e37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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