From 1c83ac114cb734ec46fa104f8a5051bb6f34acb1 Mon Sep 17 00:00:00 2001 From: Alex Myers Date: Mon, 22 Jul 2024 15:55:57 -0500 Subject: [PATCH] Reckless: make version output compatible with json option This previously exited early without allowing the reply_json call to occur. --- tools/reckless | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/reckless b/tools/reckless index b4a18c562fde..be33e5ef9415 100755 --- a/tools/reckless +++ b/tools/reckless @@ -1567,6 +1567,12 @@ def list_source(): return sources_from_file() +def report_version() -> str: + """return reckless version""" + log.info(__VERSION__) + log.add_result(__VERSION__) + + class StoreIdempotent(argparse.Action): """Make the option idempotent. This adds a secondary argument that doesn't get reinitialized. The downside is it""" @@ -1649,6 +1655,9 @@ if __name__ == '__main__': '"reckless -h"') help_cmd.add_argument('targets', type=str, nargs='*') help_cmd.set_defaults(func=help_alias) + parser.add_argument('-V', '--version', + action=StoreTrueIdempotent, const=None, + help='print version and exit') all_parsers = [parser, install_cmd, uninstall_cmd, search_cmd, enable_cmd, disable_cmd, list_parse, source_add, source_rem, help_cmd] @@ -1671,8 +1680,6 @@ if __name__ == '__main__': type=str) p.add_argument('-v', '--verbose', action=StoreTrueIdempotent, const=None) - p.add_argument('-V', '--version', action='store_true', - help='return reckless version and exit') p.add_argument('-j', '--json', action=StoreTrueIdempotent, help='output in json format') @@ -1691,7 +1698,7 @@ if __name__ == '__main__': SUPPORTED_NETWORKS = ['bitcoin', 'regtest', 'liquid', 'liquid-regtest', 'litecoin', 'signet', 'testnet'] if args.version: - log.info(__VERSION__) + report_version() elif args.cmd1 is None: parser.print_help(sys.stdout) sys.exit(1)