Skip to content

Commit 4161a8d

Browse files
committed
Command help/description improvements for 'new', 'import' and 'add'
1 parent e535766 commit 4161a8d

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

mbed/mbed.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,15 +1336,17 @@ def formaturl(url, format="default"):
13361336

13371337
# Subparser handling
13381338
parser = argparse.ArgumentParser(prog='mbed',
1339-
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 guides at www.mbed.com/cli_help" % ver,
1340-
formatter_class=argparse.RawDescriptionHelpFormatter)
1339+
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 www.mbed.com/cli_help" % ver,
1340+
formatter_class=argparse.RawTextHelpFormatter)
13411341
subparsers = parser.add_subparsers(title="Commands", metavar=" ")
13421342

13431343
# Process handling
13441344
def subcommand(name, *args, **kwargs):
13451345
def subcommand(command):
13461346
if not kwargs.get('description') and kwargs.get('help'):
13471347
kwargs['description'] = kwargs['help']
1348+
if not kwargs.get('formatter_class'):
1349+
kwargs['formatter_class'] = argparse.RawDescriptionHelpFormatter
13481350

13491351
subparser = subparsers.add_parser(name, **kwargs)
13501352

@@ -1385,8 +1387,12 @@ def thunk(parsed_args):
13851387
dict(name='--create-only', action='store_true', help='Only create a program, do not import mbed-os or mbed library.'),
13861388
dict(name='--depth', nargs='?', help='Number of revisions to fetch the mbed OS repository when creating new program. Default: all revisions.'),
13871389
dict(name='--protocol', nargs='?', help='Transport protocol when fetching the mbed OS repository when creating new program. Supported: https, http, ssh, git. Default: inferred from URL.'),
1388-
description='Creates a new mbed program if executed within a non-program location. Alternatively creates an mbed library if executed within an existing mbed program.\nThe latest mbed-os release will be downloaded/added as well if a new program is created (unless --create-only is specified).\nSupported source control management: git, hg',
1389-
help='Create new mbed program or library')
1390+
help='Create new mbed program or library',
1391+
description=(
1392+
"Creates a new mbed program if executed within a non-program location.\n"
1393+
"Alternatively creates an mbed library if executed within an existing() program.\n"
1394+
"When creating new program, the latest mbed-os release will be downloaded/added\n unless --create-only is specified.\n"
1395+
"Supported source control management: git, hg"))
13901396
def new(name, scm='git', program=False, library=False, mbedlib=False, create_only=False, depth=None, protocol=None):
13911397
global cwd_root
13921398

@@ -1454,8 +1460,9 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
14541460
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to cloning and updating.'),
14551461
dict(name='--depth', nargs='?', help='Number of revisions to fetch from the remote repository. Default: all revisions.'),
14561462
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
1457-
description='Import a program and its dependencies into the current directory or specified destination path.',
1458-
help='Import program from URL')
1463+
help='Import program from URL',
1464+
description=(
1465+
"Imports mbed program and its dependencies from a source control based URL\n(GitHub, Bitbucket, mbed.org) into the current directory or\nspecified path.\nUse 'mbed add <URL>' to add a library into an existing program."))
14591466
def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
14601467
global cwd_root
14611468

@@ -1515,8 +1522,11 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
15151522
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to cloning and updating.'),
15161523
dict(name='--depth', nargs='?', help='Number of revisions to fetch from the remote repository. Default: all revisions.'),
15171524
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
1518-
description='Add a library and its dependencies into the current %s or specified destination path.' % cwd_type,
1519-
help='Add library from URL')
1525+
help='Add library from URL',
1526+
description=(
1527+
"Adds mbed library and its dependencies from a source control based URL\n"
1528+
"(GitHub, Bitbucket, mbed.org) into an existing program.\n"
1529+
"Use 'mbed import <URL>' to import as a program"))
15201530
def add(url, path=None, ignore=False, depth=None, protocol=None, top=True):
15211531
repo = Repo.fromrepo()
15221532

0 commit comments

Comments
 (0)