From 791e521179636fd2832ff0ef656bae267bf83eea Mon Sep 17 00:00:00 2001 From: Alex Myers Date: Thu, 20 Oct 2022 14:43:55 -0500 Subject: [PATCH] reckless: update help alias `reckless help ` previously called the function docstring. This could be updated to use the subparser help, but would require a strict naming convention or a dictionary. Providing a hint to use the built-in contextual help via the option flag is hopefully sufficient. --- tools/reckless | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/reckless b/tools/reckless index da5e370ea..fd0b791cd 100755 --- a/tools/reckless +++ b/tools/reckless @@ -232,12 +232,12 @@ class InferInstall(): raise Exception(f'plugin entrypoint not found in {self.dir}') -def help(target): - if len(target) > 0: - if target[0] in globals() and hasattr(globals()[target[0]], '__doc__'): - print(globals()[target[0]].__doc__) - else: +def help_alias(target): + if len(target) == 0: parser.print_help(sys.stdout) + else: + print('try "reckless {} -h"'.format(' '.join(target))) + sys.exit(1) def verbose(*args): @@ -697,9 +697,10 @@ if __name__ == '__main__': source_rem.add_argument('targets', type=str, nargs='*') source_rem.set_defaults(func=remove_source) - help_cmd = cmd1.add_parser('help', help='display this message') + help_cmd = cmd1.add_parser('help', help='for contextual help, use ' + '"reckless -h"') help_cmd.add_argument('targets', type=str, nargs='*') - help_cmd.set_defaults(func=help) + help_cmd.set_defaults(func=help_alias) args = parser.parse_args()