Skip to content

Commit 45b425c

Browse files
committed
Add --version which prints mbed CLI version number. #222
1 parent 7bee27a commit 45b425c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mbed/mbed.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,7 @@ def formaturl(url, format="default"):
13711371
description="Command-line code management tool for ARM mbed OS - http://www.mbed.com\nversion %s\n\nUse 'mbed <command> -h|--help' for detailed help.\nOnline manual and guide available at https://github.com/ARMmbed/mbed-cli" % ver,
13721372
formatter_class=argparse.RawTextHelpFormatter)
13731373
subparsers = parser.add_subparsers(title="Commands", metavar=" ")
1374+
parser.add_argument("--version", action="store_true", dest="version", help="print version number and exit")
13741375

13751376
# Process handling
13761377
def subcommand(name, *args, **kwargs):
@@ -2173,12 +2174,15 @@ def toolchain_(name=None, global_cfg=False):
21732174
@subcommand('help',
21742175
help='This help screen')
21752176
def help_():
2176-
parser.print_help()
2177-
return
2177+
return parser.print_help()
21782178

21792179
# Parse/run command
21802180
if len(sys.argv) <= 1:
2181-
parser.print_help()
2181+
help_()
2182+
sys.exit(1)
2183+
2184+
if '--version' in sys.argv:
2185+
print ver
21822186
sys.exit(1)
21832187

21842188
pargs, remainder = parser.parse_known_args()

0 commit comments

Comments
 (0)