diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2020-01-24 19:28:20 -0600 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2020-01-24 17:28:20 -0800 |
commit | dcd8d7a620ad247daf0da771ea22859f9e651ca6 (patch) | |
tree | 0309d80d46fe370de63060589636c7db3263682b /lib | |
parent | 12a261523e2d3d21c8ea98eddee581a9fdd4a3ce (diff) | |
download | spack-dcd8d7a620ad247daf0da771ea22859f9e651ca6.tar.gz spack-dcd8d7a620ad247daf0da771ea22859f9e651ca6.tar.bz2 spack-dcd8d7a620ad247daf0da771ea22859f9e651ca6.tar.xz spack-dcd8d7a620ad247daf0da771ea22859f9e651ca6.zip |
Add spack config list command for tab completion (#14474)
* Add spack config list command for tab completion
* Update tab completion scripts
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/config.py | 21 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/config.py | 6 |
2 files changed, 22 insertions, 5 deletions
diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py index b6055a7f6b..b1a6454555 100644 --- a/lib/spack/spack/cmd/config.py +++ b/lib/spack/spack/cmd/config.py @@ -56,6 +56,8 @@ def setup_parser(subparser): '--print-file', action='store_true', help="print the file name that would be edited") + sp.add_parser('list', help='list configuration sections') + def _get_scope_and_section(args): """Extract config scope and section from arguments.""" @@ -83,7 +85,6 @@ def config_get(args): With no arguments and an active environment, print the contents of the environment's manifest file (spack.yaml). - """ scope, section = _get_scope_and_section(args) @@ -113,7 +114,6 @@ def config_edit(args): With no arguments and an active environment, edit the spack.yaml for the active environment. - """ scope, section = _get_scope_and_section(args) if not scope and not section: @@ -127,8 +127,19 @@ def config_edit(args): editor(config_file) +def config_list(args): + """List the possible configuration sections. + + Used primarily for shell tab completion scripts. + """ + print(' '.join(list(spack.config.section_schemas))) + + def config(parser, args): - action = {'get': config_get, - 'blame': config_blame, - 'edit': config_edit} + action = { + 'get': config_get, + 'blame': config_blame, + 'edit': config_edit, + 'list': config_list, + } action[args.config_command](args) diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py index 34982d46b3..82a9d814ea 100644 --- a/lib/spack/spack/test/cmd/config.py +++ b/lib/spack/spack/test/cmd/config.py @@ -91,3 +91,9 @@ def test_config_edit_fails_correctly_with_no_env(mutable_mock_env_path): def test_config_get_fails_correctly_with_no_env(mutable_mock_env_path): output = config('get', fail_on_error=False) assert "requires a section argument or an active environment" in output + + +def test_config_list(): + output = config('list') + assert 'compilers' in output + assert 'packages' in output |