Skip to content

Commit

Permalink
CLI: Do not execute a command if help is printed
Browse files Browse the repository at this point in the history
Previously, for example `hf 14a raw -b 7 -d 26 -h` was printing help but it was also executing the command.
  • Loading branch information
doegox committed Nov 15, 2023
1 parent 5b67a89 commit af91ddc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions software/script/chameleon_cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def exec_cmd(self, cmd_str):
args.prog = tree_node.fullname
try:
args_parse_result = args.parse_args(arg_list)
if args.help_requested:
return
except chameleon_utils.ArgsParserError as e:
args.print_help()
print(f'{CY}'+str(e).strip()+f'{C0}', end="\n\n")
Expand Down
3 changes: 3 additions & 0 deletions software/script/chameleon_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.add_help = False
self.description = "Please enter correct parameters"
self.help_requested = False

def exit(self, status: int = 0, message: Union[str, None] = None):
if message:
Expand Down Expand Up @@ -98,6 +99,8 @@ def print_help(self):
if len(lines) > 0:
lines[0] = f'{CG}{lines[0]}{C0}'
print('\n'.join(lines))
print('')
self.help_requested = True


def expect_response(accepted_responses: Union[int, list[int]]) -> Callable[..., Any]:
Expand Down

0 comments on commit af91ddc

Please sign in to comment.