mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
CLI: Do not execute a command if help is printed
Previously, for example `hf 14a raw -b 7 -d 26 -h` was printing help but it was also executing the command.
This commit is contained in:
@@ -119,6 +119,8 @@ class ChameleonCLI:
|
||||
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")
|
||||
|
||||
@@ -43,6 +43,7 @@ class ArgumentParserNoExit(argparse.ArgumentParser):
|
||||
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:
|
||||
@@ -98,6 +99,8 @@ class ArgumentParserNoExit(argparse.ArgumentParser):
|
||||
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]:
|
||||
|
||||
Reference in New Issue
Block a user