Clean up help metavar for --scope configuration options

- previously commands with this argument showed a long list of choices
  that were platform specific.

- use a better metavar: {defaults,system,site,user}[/PLATFORM]
This commit is contained in:
Todd Gamblin 2018-02-10 21:53:24 -05:00
parent de3c047105
commit 2b7dfcd19f
6 changed files with 32 additions and 14 deletions

View File

@ -54,7 +54,8 @@ def setup_parser(subparser):
help='search the system for compilers to add to Spack configuration') help='search the system for compilers to add to Spack configuration')
find_parser.add_argument('add_paths', nargs=argparse.REMAINDER) find_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
find_parser.add_argument( find_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_modify_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_modify_scope,
help="configuration scope to modify") help="configuration scope to modify")
# Remove # Remove
@ -65,20 +66,23 @@ def setup_parser(subparser):
help='remove ALL compilers that match spec') help='remove ALL compilers that match spec')
remove_parser.add_argument('compiler_spec') remove_parser.add_argument('compiler_spec')
remove_parser.add_argument( remove_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_modify_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_modify_scope,
help="configuration scope to modify") help="configuration scope to modify")
# List # List
list_parser = sp.add_parser('list', help='list available compilers') list_parser = sp.add_parser('list', help='list available compilers')
list_parser.add_argument( list_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_list_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_list_scope,
help="configuration scope to read from") help="configuration scope to read from")
# Info # Info
info_parser = sp.add_parser('info', help='show compiler paths') info_parser = sp.add_parser('info', help='show compiler paths')
info_parser.add_argument('compiler_spec') info_parser.add_argument('compiler_spec')
info_parser.add_argument( info_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_list_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_list_scope,
help="configuration scope to read from") help="configuration scope to read from")

View File

@ -31,8 +31,10 @@
def setup_parser(subparser): def setup_parser(subparser):
subparser.add_argument('--scope', choices=spack.config.config_scopes, scopes = spack.config.config_scopes
help="configuration scope to read/modify") subparser.add_argument(
'--scope', choices=scopes, metavar=spack.config.scopes_metavar,
help="configuration scope to read/modify")
def compilers(parser, args): def compilers(parser, args):

View File

@ -31,8 +31,10 @@
def setup_parser(subparser): def setup_parser(subparser):
# User can only choose one # User can only choose one
subparser.add_argument('--scope', choices=spack.config.config_scopes, subparser.add_argument(
help="configuration scope to read/modify") '--scope', choices=spack.config.config_scopes,
metavar=spack.config.scopes_metavar,
help="configuration scope to read/modify")
sp = subparser.add_subparsers(metavar='SUBCOMMAND', dest='config_command') sp = subparser.add_subparsers(metavar='SUBCOMMAND', dest='config_command')

View File

@ -75,7 +75,8 @@ def setup_parser(subparser):
add_parser.add_argument( add_parser.add_argument(
'url', help="url of mirror directory from 'spack mirror create'") 'url', help="url of mirror directory from 'spack mirror create'")
add_parser.add_argument( add_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_modify_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_modify_scope,
help="configuration scope to modify") help="configuration scope to modify")
# Remove # Remove
@ -83,13 +84,15 @@ def setup_parser(subparser):
help=mirror_remove.__doc__) help=mirror_remove.__doc__)
remove_parser.add_argument('name') remove_parser.add_argument('name')
remove_parser.add_argument( remove_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_modify_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_modify_scope,
help="configuration scope to modify") help="configuration scope to modify")
# List # List
list_parser = sp.add_parser('list', help=mirror_list.__doc__) list_parser = sp.add_parser('list', help=mirror_list.__doc__)
list_parser.add_argument( list_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_list_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_list_scope,
help="configuration scope to read from") help="configuration scope to read from")

View File

@ -52,7 +52,8 @@ def setup_parser(subparser):
# List # List
list_parser = sp.add_parser('list', help=repo_list.__doc__) list_parser = sp.add_parser('list', help=repo_list.__doc__)
list_parser.add_argument( list_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_list_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_list_scope,
help="configuration scope to read from") help="configuration scope to read from")
# Add # Add
@ -60,7 +61,8 @@ def setup_parser(subparser):
add_parser.add_argument( add_parser.add_argument(
'path', help="path to a Spack package repository directory") 'path', help="path to a Spack package repository directory")
add_parser.add_argument( add_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_modify_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_modify_scope,
help="configuration scope to modify") help="configuration scope to modify")
# Remove # Remove
@ -70,7 +72,8 @@ def setup_parser(subparser):
'path_or_namespace', 'path_or_namespace',
help="path or namespace of a Spack package repository") help="path or namespace of a Spack package repository")
remove_parser.add_argument( remove_parser.add_argument(
'--scope', choices=scopes, default=spack.cmd.default_modify_scope, '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
default=spack.cmd.default_modify_scope,
help="configuration scope to modify") help="configuration scope to modify")

View File

@ -88,6 +88,10 @@
#: Later scopes will override earlier scopes. #: Later scopes will override earlier scopes.
config_scopes = OrderedDict() config_scopes = OrderedDict()
#: metavar to use for commands that accept scopes
#: this is shorter and more readable than listing all choices
scopes_metavar = '{defaults,system,site,user}[/PLATFORM]'
def validate_section_name(section): def validate_section_name(section):
"""Exit if the section is not a valid section.""" """Exit if the section is not a valid section."""