From c3506911c07f1cb9a7a34fe69bd1e2a80d9e0047 Mon Sep 17 00:00:00 2001 From: johlar <8424941+johlar@users.noreply.github.com> Date: Tue, 15 Feb 2022 19:51:20 +0100 Subject: [PATCH] Add support for cli --version command --- electrum/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/electrum/commands.py b/electrum/commands.py index de1313dd6..b7d3ee3de 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -1380,7 +1380,7 @@ def set_default_subparser(self, name, args=None): """see http://stackoverflow.com/questions/5176691/argparse-how-to-specify-a-default-subcommand""" subparser_found = False for arg in sys.argv[1:]: - if arg in ['-h', '--help']: # global help if no subparser + if arg in ['-h', '--help', '--version']: # global help/version if no subparser break else: for x in self._subparsers._actions: @@ -1457,6 +1457,7 @@ def get_parser(): # create main parser parser = argparse.ArgumentParser( epilog="Run 'electrum help ' to see the help for a command") + parser.add_argument("--version", dest="cmd", action='store_const', const='version', help="Return the version of Electrum.") add_global_options(parser) add_wallet_option(parser) subparsers = parser.add_subparsers(dest='cmd', metavar='')