summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-02-10 21:53:24 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2018-02-12 20:25:17 -0800
commit2b7dfcd19faf08901b59eadc933bc3963088c8cc (patch)
tree470257391097fe8aa25b2231a9bbf1856e6db4d6
parentde3c047105b49528b2d5531f63d70b4e1fbe81a4 (diff)
downloadspack-2b7dfcd19faf08901b59eadc933bc3963088c8cc.tar.gz
spack-2b7dfcd19faf08901b59eadc933bc3963088c8cc.tar.bz2
spack-2b7dfcd19faf08901b59eadc933bc3963088c8cc.tar.xz
spack-2b7dfcd19faf08901b59eadc933bc3963088c8cc.zip
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]
-rw-r--r--lib/spack/spack/cmd/compiler.py12
-rw-r--r--lib/spack/spack/cmd/compilers.py6
-rw-r--r--lib/spack/spack/cmd/config.py6
-rw-r--r--lib/spack/spack/cmd/mirror.py9
-rw-r--r--lib/spack/spack/cmd/repo.py9
-rw-r--r--lib/spack/spack/config.py4
6 files changed, 32 insertions, 14 deletions
diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py
index e7be196b1f..c133a85876 100644
--- a/lib/spack/spack/cmd/compiler.py
+++ b/lib/spack/spack/cmd/compiler.py
@@ -54,7 +54,8 @@ def setup_parser(subparser):
help='search the system for compilers to add to Spack configuration')
find_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
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")
# Remove
@@ -65,20 +66,23 @@ def setup_parser(subparser):
help='remove ALL compilers that match spec')
remove_parser.add_argument('compiler_spec')
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")
# List
list_parser = sp.add_parser('list', help='list available compilers')
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")
# Info
info_parser = sp.add_parser('info', help='show compiler paths')
info_parser.add_argument('compiler_spec')
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")
diff --git a/lib/spack/spack/cmd/compilers.py b/lib/spack/spack/cmd/compilers.py
index 7895d11d94..f23ba5cc68 100644
--- a/lib/spack/spack/cmd/compilers.py
+++ b/lib/spack/spack/cmd/compilers.py
@@ -31,8 +31,10 @@ level = "short"
def setup_parser(subparser):
- subparser.add_argument('--scope', choices=spack.config.config_scopes,
- help="configuration scope to read/modify")
+ scopes = spack.config.config_scopes
+ subparser.add_argument(
+ '--scope', choices=scopes, metavar=spack.config.scopes_metavar,
+ help="configuration scope to read/modify")
def compilers(parser, args):
diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py
index f2325e73e0..7614d5a09a 100644
--- a/lib/spack/spack/cmd/config.py
+++ b/lib/spack/spack/cmd/config.py
@@ -31,8 +31,10 @@ level = "long"
def setup_parser(subparser):
# User can only choose one
- subparser.add_argument('--scope', choices=spack.config.config_scopes,
- help="configuration scope to read/modify")
+ subparser.add_argument(
+ '--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')
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 35d31adb2d..cd59be5782 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -75,7 +75,8 @@ def setup_parser(subparser):
add_parser.add_argument(
'url', help="url of mirror directory from 'spack mirror create'")
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")
# Remove
@@ -83,13 +84,15 @@ def setup_parser(subparser):
help=mirror_remove.__doc__)
remove_parser.add_argument('name')
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")
# List
list_parser = sp.add_parser('list', help=mirror_list.__doc__)
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")
diff --git a/lib/spack/spack/cmd/repo.py b/lib/spack/spack/cmd/repo.py
index 0b5ced1642..9fbce6137b 100644
--- a/lib/spack/spack/cmd/repo.py
+++ b/lib/spack/spack/cmd/repo.py
@@ -52,7 +52,8 @@ def setup_parser(subparser):
# List
list_parser = sp.add_parser('list', help=repo_list.__doc__)
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")
# Add
@@ -60,7 +61,8 @@ def setup_parser(subparser):
add_parser.add_argument(
'path', help="path to a Spack package repository directory")
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")
# Remove
@@ -70,7 +72,8 @@ def setup_parser(subparser):
'path_or_namespace',
help="path or namespace of a Spack package repository")
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")
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index 53e5eccf3b..7b56328621 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -88,6 +88,10 @@ section_schemas = {
#: Later scopes will override earlier scopes.
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):
"""Exit if the section is not a valid section."""