Add spack config list command for tab completion (#14474)
* Add spack config list command for tab completion * Update tab completion scripts
This commit is contained in:
parent
12a261523e
commit
dcd8d7a620
@ -56,6 +56,8 @@ def setup_parser(subparser):
|
|||||||
'--print-file', action='store_true',
|
'--print-file', action='store_true',
|
||||||
help="print the file name that would be edited")
|
help="print the file name that would be edited")
|
||||||
|
|
||||||
|
sp.add_parser('list', help='list configuration sections')
|
||||||
|
|
||||||
|
|
||||||
def _get_scope_and_section(args):
|
def _get_scope_and_section(args):
|
||||||
"""Extract config scope and section from arguments."""
|
"""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
|
With no arguments and an active environment, print the contents of
|
||||||
the environment's manifest file (spack.yaml).
|
the environment's manifest file (spack.yaml).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
scope, section = _get_scope_and_section(args)
|
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
|
With no arguments and an active environment, edit the spack.yaml for
|
||||||
the active environment.
|
the active environment.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
scope, section = _get_scope_and_section(args)
|
scope, section = _get_scope_and_section(args)
|
||||||
if not scope and not section:
|
if not scope and not section:
|
||||||
@ -127,8 +127,19 @@ def config_edit(args):
|
|||||||
editor(config_file)
|
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):
|
def config(parser, args):
|
||||||
action = {'get': config_get,
|
action = {
|
||||||
'blame': config_blame,
|
'get': config_get,
|
||||||
'edit': config_edit}
|
'blame': config_blame,
|
||||||
|
'edit': config_edit,
|
||||||
|
'list': config_list,
|
||||||
|
}
|
||||||
action[args.config_command](args)
|
action[args.config_command](args)
|
||||||
|
@ -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):
|
def test_config_get_fails_correctly_with_no_env(mutable_mock_env_path):
|
||||||
output = config('get', fail_on_error=False)
|
output = config('get', fail_on_error=False)
|
||||||
assert "requires a section argument or an active environment" in output
|
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
|
||||||
|
@ -218,7 +218,7 @@ _keys() {
|
|||||||
_config_sections() {
|
_config_sections() {
|
||||||
if [[ -z "${SPACK_CONFIG_SECTIONS:-}" ]]
|
if [[ -z "${SPACK_CONFIG_SECTIONS:-}" ]]
|
||||||
then
|
then
|
||||||
SPACK_CONFIG_SECTIONS="compilers mirrors repos packages modules config upstreams"
|
SPACK_CONFIG_SECTIONS="$(spack config list)"
|
||||||
fi
|
fi
|
||||||
SPACK_COMPREPLY="$SPACK_CONFIG_SECTIONS"
|
SPACK_COMPREPLY="$SPACK_CONFIG_SECTIONS"
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ _keys() {
|
|||||||
_config_sections() {
|
_config_sections() {
|
||||||
if [[ -z "${SPACK_CONFIG_SECTIONS:-}" ]]
|
if [[ -z "${SPACK_CONFIG_SECTIONS:-}" ]]
|
||||||
then
|
then
|
||||||
SPACK_CONFIG_SECTIONS="compilers mirrors repos packages modules config upstreams"
|
SPACK_CONFIG_SECTIONS="$(spack config list)"
|
||||||
fi
|
fi
|
||||||
SPACK_COMPREPLY="$SPACK_CONFIG_SECTIONS"
|
SPACK_COMPREPLY="$SPACK_CONFIG_SECTIONS"
|
||||||
}
|
}
|
||||||
@ -584,7 +584,7 @@ _spack_config() {
|
|||||||
then
|
then
|
||||||
SPACK_COMPREPLY="-h --help --scope"
|
SPACK_COMPREPLY="-h --help --scope"
|
||||||
else
|
else
|
||||||
SPACK_COMPREPLY="get blame edit"
|
SPACK_COMPREPLY="get blame edit list"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,6 +615,10 @@ _spack_config_edit() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_spack_config_list() {
|
||||||
|
SPACK_COMPREPLY="-h --help"
|
||||||
|
}
|
||||||
|
|
||||||
_spack_configure() {
|
_spack_configure() {
|
||||||
if $list_options
|
if $list_options
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user