spack extensions prints list of extendable packages (#14473)
* spack extensions prints list of extendable packages * Update tab completion scripts
This commit is contained in:
parent
9f89dce52f
commit
342200774b
@ -4,6 +4,7 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.tty.colify import colify
|
from llnl.util.tty.colify import colify
|
||||||
@ -21,6 +22,8 @@
|
|||||||
|
|
||||||
|
|
||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
|
subparser.epilog = 'If called without argument returns ' \
|
||||||
|
'the list of all valid extendable packages'
|
||||||
arguments.add_common_arguments(subparser, ['long', 'very_long'])
|
arguments.add_common_arguments(subparser, ['long', 'very_long'])
|
||||||
subparser.add_argument('-d', '--deps', action='store_true',
|
subparser.add_argument('-d', '--deps', action='store_true',
|
||||||
help='output dependencies along with found specs')
|
help='output dependencies along with found specs')
|
||||||
@ -42,7 +45,19 @@ def setup_parser(subparser):
|
|||||||
|
|
||||||
def extensions(parser, args):
|
def extensions(parser, args):
|
||||||
if not args.spec:
|
if not args.spec:
|
||||||
tty.die("extensions requires a package spec.")
|
# If called without arguments, list all the extendable packages
|
||||||
|
isatty = sys.stdout.isatty()
|
||||||
|
if isatty:
|
||||||
|
tty.info('Extendable packages:')
|
||||||
|
|
||||||
|
extendable_pkgs = []
|
||||||
|
for name in spack.repo.all_package_names():
|
||||||
|
pkg = spack.repo.get(name)
|
||||||
|
if pkg.extendable:
|
||||||
|
extendable_pkgs.append(name)
|
||||||
|
|
||||||
|
colify(extendable_pkgs, indent=4)
|
||||||
|
return
|
||||||
|
|
||||||
# Checks
|
# Checks
|
||||||
spec = cmd.parse_specs(args.spec)
|
spec = cmd.parse_specs(args.spec)
|
||||||
|
@ -69,6 +69,11 @@ def check_output(ni, na):
|
|||||||
check_output(1, 1)
|
check_output(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_extensions_no_arguments(mock_packages):
|
||||||
|
out = extensions()
|
||||||
|
assert 'python' in out
|
||||||
|
|
||||||
|
|
||||||
def test_extensions_raises_if_not_extendable(mock_packages):
|
def test_extensions_raises_if_not_extendable(mock_packages):
|
||||||
with pytest.raises(SpackCommandError):
|
with pytest.raises(SpackCommandError):
|
||||||
extensions("flake8")
|
extensions("flake8")
|
||||||
|
@ -226,7 +226,7 @@ _config_sections() {
|
|||||||
_extensions() {
|
_extensions() {
|
||||||
if [[ -z "${SPACK_EXTENSIONS:-}" ]]
|
if [[ -z "${SPACK_EXTENSIONS:-}" ]]
|
||||||
then
|
then
|
||||||
SPACK_EXTENSIONS="aspell go-bootstrap go icedtea jdk kim-api lua matlab mofem-cephas octave openjdk perl python r ruby rust tcl yorick"
|
SPACK_EXTENSIONS="$(spack extensions)"
|
||||||
fi
|
fi
|
||||||
SPACK_COMPREPLY="$SPACK_EXTENSIONS"
|
SPACK_COMPREPLY="$SPACK_EXTENSIONS"
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ _config_sections() {
|
|||||||
_extensions() {
|
_extensions() {
|
||||||
if [[ -z "${SPACK_EXTENSIONS:-}" ]]
|
if [[ -z "${SPACK_EXTENSIONS:-}" ]]
|
||||||
then
|
then
|
||||||
SPACK_EXTENSIONS="aspell go-bootstrap go icedtea jdk kim-api lua matlab mofem-cephas octave openjdk perl python r ruby rust tcl yorick"
|
SPACK_EXTENSIONS="$(spack extensions)"
|
||||||
fi
|
fi
|
||||||
SPACK_COMPREPLY="$SPACK_EXTENSIONS"
|
SPACK_COMPREPLY="$SPACK_EXTENSIONS"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user