Skip to content

Commit 7bee05e

Browse files
committed
Significant improvements to mbed CLI command help and descriptions
1 parent 4161a8d commit 7bee05e

File tree

1 file changed

+67
-33
lines changed

1 file changed

+67
-33
lines changed

mbed/mbed.py

Lines changed: 67 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def thunk(parsed_args):
13901390
help='Create new mbed program or library',
13911391
description=(
13921392
"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"
1393+
"Alternatively creates an mbed library if executed within an existing program.\n"
13941394
"When creating new program, the latest mbed-os release will be downloaded/added\n unless --create-only is specified.\n"
13951395
"Supported source control management: git, hg"))
13961396
def new(name, scm='git', program=False, library=False, mbedlib=False, create_only=False, depth=None, protocol=None):
@@ -1462,7 +1462,9 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
14621462
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
14631463
help='Import program from URL',
14641464
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."))
1465+
"Imports mbed program and its dependencies from a source control based URL\n"
1466+
"(GitHub, Bitbucket, mbed.org) into the current directory or specified\npath.\n"
1467+
"Use 'mbed add <URL>' to add a library into an existing program."))
14661468
def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
14671469
global cwd_root
14681470

@@ -1545,8 +1547,10 @@ def add(url, path=None, ignore=False, depth=None, protocol=None, top=True):
15451547
# Remove library
15461548
@subcommand('remove',
15471549
dict(name='path', help='Local library name or path'),
1548-
description='Remove specified library and its dependencies from the current %s.' % cwd_type,
1549-
help='Remove library')
1550+
help='Remove library',
1551+
description=(
1552+
"Remove specified library, its dependencies and references from the current\n"
1553+
"You can re-add the library from it's URL via 'mbed add <library URL>'."))
15501554
def remove(path):
15511555
repo = Repo.fromrepo()
15521556
if not Repo.isrepo(path):
@@ -1564,8 +1568,11 @@ def remove(path):
15641568
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to cloning and updating.'),
15651569
dict(name='--depth', nargs='?', help='Number of revisions to fetch from the remote repository. Default: all revisions.'),
15661570
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
1567-
description='Import missing dependencies in the current program or library.',
1568-
help='Find and add missing libraries')
1571+
help='Find and add missing libraries',
1572+
description=(
1573+
"Import missing dependencies in an existing program or library.\n"
1574+
"Use 'mbed import <URL>' and 'mbed add <URL>' instead of cloning manually and\n"
1575+
"then running 'mbed deploy'"))
15691576
def deploy(ignore=False, depth=None, protocol=None, top=True):
15701577
repo = Repo.fromrepo()
15711578
repo.ignores()
@@ -1585,9 +1592,14 @@ def deploy(ignore=False, depth=None, protocol=None, top=True):
15851592

15861593
# Publish command
15871594
@subcommand('publish',
1588-
dict(name=['-A', '--all'], action='store_true', help='Publish all branches, including new. Default: push only the current branch.'),
1589-
description='Publish current %s and its dependencies to associated remote repository URLs.' % cwd_type,
1590-
help='Publish program or library')
1595+
dict(name=['-A', '--all'], action='store_true', help='Publish all branches, including new ones. Default: push only the current branch.'),
1596+
help='Publish program or library',
1597+
description=(
1598+
"Publishes this %s and all dependencies to their associated remote\nrepository URLs.\n"
1599+
"This command performs various consistency checks for local uncommitted changes\n"
1600+
"and unpublished revisions and encourages to commit/push them.\n"
1601+
"Online guide about collaboration is available at:\n"
1602+
"www.mbed.com/collab_guide" % cwd_type))
15911603
def publish(all=None, top=True):
15921604
if top:
15931605
action("Checking for local modifications...")
@@ -1629,8 +1641,11 @@ def publish(all=None, top=True):
16291641
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to unpublished libraries, unpublished or uncommitted changes, and attempt to update from associated remote repository URLs.'),
16301642
dict(name='--depth', nargs='?', help='Number of revisions to fetch from the remote repository. Default: all revisions.'),
16311643
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
1632-
description='Update current %s and its dependencies from associated remote repository URLs.' % cwd_type,
1633-
help='Update to branch, tag, revision or latest')
1644+
help='Update to branch, tag, revision or latest',
1645+
description=(
1646+
"Updates this %s and its dependencies to specified branch, tag or revision.\n"
1647+
"Alternatively fetches from associated remote repository URL and updates to the\n"
1648+
"latest revision in the current branch." % cwd_type))
16341649
def update(rev=None, clean=False, force=False, ignore=False, top=True, depth=None, protocol=None):
16351650
if top and clean:
16361651
sync()
@@ -1724,8 +1739,11 @@ def update(rev=None, clean=False, force=False, ignore=False, top=True, depth=Non
17241739

17251740
# Synch command
17261741
@subcommand('sync',
1727-
description='Synchronize dependency references (.lib files) in the current %s.' % cwd_type,
1728-
help='Synchronize library references')
1742+
help='Synchronize library references',
1743+
description=(
1744+
"Synchronizes all library and dependency references (.lib files) in the\n"
1745+
"current %s.\n"
1746+
"Note that this will remove all invalid library references." % cwd_type))
17291747
def sync(recursive=True, keep_refs=False, top=True):
17301748
if top and recursive:
17311749
action("Synchronizing dependency references...")
@@ -1783,8 +1801,9 @@ def sync(recursive=True, keep_refs=False, top=True):
17831801
@subcommand('ls',
17841802
dict(name=['-a', '--all'], action='store_true', help='List repository URL and revision pairs'),
17851803
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to missing libraries.'),
1786-
description='View the current %s dependency tree.' % cwd_type,
1787-
help='View library tree')
1804+
help='View dependency tree',
1805+
description=(
1806+
"View the dependency tree in this %s." % cwd_type))
17881807
def list_(all=False, prefix='', p_path=None, ignore=False):
17891808
repo = Repo.fromrepo()
17901809
print prefix + (relpath(p_path, repo.path) if p_path else repo.name), '(%s)' % ((repo.fullurl if all else repo.rev) or 'no revision')
@@ -1804,8 +1823,9 @@ def list_(all=False, prefix='', p_path=None, ignore=False):
18041823
# Command status for cross-SCM status of repositories
18051824
@subcommand('status',
18061825
dict(name=['-I', '--ignore'], action='store_true', help='Ignore errors related to missing libraries.'),
1807-
description='Show changes status of the current %s and its dependencies.' % cwd_type,
1808-
help='Show version control status\n\n')
1826+
help='Show version control status\n\n',
1827+
description=(
1828+
"Show uncommitted changes in this %s and its dependencies." % cwd_type))
18091829
def status_(ignore=False):
18101830
repo = Repo.fromrepo()
18111831
if repo.dirty():
@@ -1822,16 +1842,16 @@ def status_(ignore=False):
18221842
@subcommand('compile',
18231843
dict(name=['-t', '--toolchain'], help='Compile toolchain. Example: ARM, uARM, GCC_ARM, IAR'),
18241844
dict(name=['-m', '--mcu'], help='Compile target. Example: K64F, NUCLEO_F401RE, NRF51822...'),
1825-
dict(name='--source', action='append', help='Source directory. Default: . (current dir)'),
1826-
dict(name='--build', help='Build directory. Default: .build/'),
18271845
dict(name='--library', dest='compile_library', action='store_true', help='Compile the current %s as a static library.' % cwd_type),
18281846
dict(name='--config', dest='compile_config', help='Show run-time compile configuration'),
18291847
dict(name='--prefix', dest='config_prefix', action='append', help='Restrict listing to parameters that have this prefix'),
18301848
dict(name='--tests', dest='compile_tests', action='store_true', help='Compile tests in TESTS directory.'),
1849+
dict(name='--source', action='append', help='Source directory. Default: . (current dir)'),
1850+
dict(name='--build', help='Build directory. Default: .build/'),
18311851
dict(name=['-c', '--clean'], action='store_true', help='Clean the build directory before compiling'),
18321852
dict(name=['-S', '--supported'], dest='supported', action='store_true', help='Shows supported matrix of targets and toolchains'),
1833-
description='Compile program using the native mbed OS build system.',
1834-
help='Compile program using the mbed build tools')
1853+
help='Compile this program using the mbed build tools',
1854+
description=("Compile this program using the mbed build tools."))
18351855
def compile(toolchain=None, mcu=None, source=False, build=False, compile_library=False, compile_config=False, config_prefix=None, compile_tests=False, clean=False, supported=False):
18361856
# Gather remaining arguments
18371857
args = remainder
@@ -1879,6 +1899,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
18791899
popen(['python', '-u', os.path.join(tools_dir, 'build.py')]
18801900
+ list(chain.from_iterable(izip(repeat('-D'), macros)))
18811901
+ ['-t', tchain, '-m', target]
1902+
+ (['-c'] if clean else [])
18821903
+ list(chain.from_iterable(izip(repeat('--source'), source)))
18831904
+ ['--build', build]
18841905
+ (['-v'] if verbose else [])
@@ -1892,6 +1913,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
18921913
popen(['python', '-u', os.path.join(tools_dir, 'make.py')]
18931914
+ list(chain.from_iterable(izip(repeat('-D'), macros)))
18941915
+ ['-t', tchain, '-m', target]
1916+
+ (['-c'] if clean else [])
18951917
+ list(chain.from_iterable(izip(repeat('--source'), source)))
18961918
+ ['--build', build]
18971919
+ (['-v'] if verbose else [])
@@ -1952,8 +1974,9 @@ def test_(list_tests=False, compile_tests=False, test_spec="test_spec.json"):
19521974
@subcommand('export',
19531975
dict(name=['-i', '--ide'], help='IDE to create project files for. Example: UVISION,DS5,IAR', required=True),
19541976
dict(name=['-m', '--mcu'], help='Export for target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...'),
1955-
description='Generate project files for desktop IDEs for the current program.',
1956-
help='Generate an IDE project')
1977+
help='Generate an IDE project',
1978+
description=(
1979+
"Generate IDE project files for the current program."))
19571980
def export(ide=None, mcu=None):
19581981
# Gather remaining arguments
19591982
args = remainder
@@ -1976,8 +1999,10 @@ def export(ide=None, mcu=None):
19761999

19772000
# Test command
19782001
@subcommand('detect',
1979-
description='Detect mbed targets/boards connected to this system.',
1980-
help='Detect connected mbed targets/boards\n\n')
2002+
help='Detect connected mbed targets/boards\n\n',
2003+
description=(
2004+
"Detects mbed targets/boards connected to this system and shows supported\n"
2005+
"toolchain matrix."))
19812006
def detect():
19822007
# Gather remaining arguments
19832008
args = remainder
@@ -2001,8 +2026,12 @@ def detect():
20012026
dict(name='value', nargs='?', help='Value. Will show the currently set default value for a variable if not specified.'),
20022027
dict(name=['-G', '--global'], dest='global_cfg', action='store_true', help='Use global settings, not local'),
20032028
dict(name=['-U', '--unset'], dest='unset', action='store_true', help='Unset the specified variable.'),
2004-
description='Set or get global options for all programs. Global options may be overridden by program defaults.',
2005-
help='Tool configuration')
2029+
help='Tool configuration',
2030+
description=(
2031+
"Gets, sets or unsets mbed tool configuration options.\n"
2032+
"Options can be global (via the --global switch) or local (per program)\n"
2033+
"Global options are always overridden by local/program options.\n"
2034+
"Currently supported options: target, toolchain, protocol, depth, cache"))
20062035
def config_(var, value=None, global_cfg=False, unset=False):
20072036
name = var
20082037
var = str(var).upper()
@@ -2037,15 +2066,20 @@ def config_(var, value=None, global_cfg=False, unset=False):
20372066
# Build system and exporters
20382067
@subcommand('target',
20392068
dict(name='name', nargs='?', help='Default target name. Example: K64F, NUCLEO_F401RE, NRF51822...'),
2040-
help='Set default target for the current program.')
2041-
def target_(name=None):
2042-
return default_('target', name)
2069+
dict(name=['-G', '--global'], dest='global_cfg', action='store_true', help='Use global settings, not local'),
2070+
help='Set or get default target',
2071+
description=(
2072+
"This is an alias to 'mbed config target [--global] [name]'\n"))
2073+
def target_(name=None, global_cfg=False):
2074+
return config_('target', name, global_cfg=global_cfg)
20432075

20442076
@subcommand('toolchain',
20452077
dict(name='name', nargs='?', help='Default toolchain name. Example: ARM, uARM, GCC_ARM, IAR'),
2046-
help='Set default toolchain for the current program.')
2047-
def toolchain_(name=None):
2048-
return default_('toolchain', name)
2078+
help='Set or get default toolchain',
2079+
description=(
2080+
"This is an alias to 'mbed config toolchain [--global] [name]'\n"))
2081+
def toolchain_(name=None, global_cfg=False):
2082+
return config_('toolchain', name, global_cfg=global_cfg)
20492083

20502084

20512085
# Parse/run command

0 commit comments

Comments
 (0)