Skip to content

Commit

Permalink
Reckless: make version output compatible with json option
Browse files Browse the repository at this point in the history
This previously exited early without allowing the reply_json call
to occur.
  • Loading branch information
endothermicdev committed Jul 24, 2024
1 parent 7c8f041 commit 1c83ac1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tools/reckless
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -1649,6 +1655,9 @@ if __name__ == '__main__':
'"reckless <cmd> -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]
Expand All @@ -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')

Expand All @@ -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)
Expand Down

0 comments on commit 1c83ac1

Please sign in to comment.