Upgrade command parser

This commit is contained in:
Dominik Szymański
2023-08-10 22:59:00 +02:00
parent f30ff7054c
commit 85b2fb3d8a
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -152,14 +152,15 @@ class ChameleonCLI:
cmds = cmd_str.split(" ")
cmd_maps: dict or types.FunctionType = self.cmd_maps
cmd_end = ""
cmd_end_position = 0
for cmd in cmds:
if cmd in cmd_maps: # CMD found in map, we can continue find next
cmd_maps = cmd_maps[cmd]
cmd_end = cmd
cmd_end_position += len(cmd) + 1
else: # CMD not found
break
cmd_end_position = cmd_str.index(cmd_end) + len(cmd_end) + 1
return cmd_maps, (cmd_str[:cmd_end_position], cmd_str[cmd_end_position:])
return cmd_maps, (cmd_str[:cmd_end_position - 1], cmd_str[cmd_end_position:])
def startCLI(self):
"""
+1 -1
View File
@@ -1013,7 +1013,7 @@ class HWSettingsAnimationSet(DeviceRequiredUnit):
def args_parser(self) -> ArgumentParserNoExit or None:
parser = ArgumentParserNoExit()
parser.add_argument('-m', '--mode', type=int, required=True, help="0 is full (default), 1 is minimal (only single pass on button wakeup), 2 is none", choices=[0, 1, 2])
return None
return parser
def on_exec(self, args: argparse.Namespace):
mode = args.mode