summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2020-02-17 17:41:48 -0600
committerGitHub <noreply@github.com>2020-02-17 17:41:47 -0600
commit342200774b9ee5441d33dc985d889b0a8f21e3e2 (patch)
tree496c8cf7a222c32a9115baae87a594b9a697ec3a
parent9f89dce52f3094736169d6ff19f870f775e719ff (diff)
downloadspack-342200774b9ee5441d33dc985d889b0a8f21e3e2.tar.gz
spack-342200774b9ee5441d33dc985d889b0a8f21e3e2.tar.bz2
spack-342200774b9ee5441d33dc985d889b0a8f21e3e2.tar.xz
spack-342200774b9ee5441d33dc985d889b0a8f21e3e2.zip
spack extensions prints list of extendable packages (#14473)
* spack extensions prints list of extendable packages * Update tab completion scripts
-rw-r--r--lib/spack/spack/cmd/extensions.py17
-rw-r--r--lib/spack/spack/test/cmd/extensions.py5
-rwxr-xr-xshare/spack/bash/spack-completion.in2
-rwxr-xr-xshare/spack/spack-completion.bash2
4 files changed, 23 insertions, 3 deletions
diff --git a/lib/spack/spack/cmd/extensions.py b/lib/spack/spack/cmd/extensions.py
index e834d7fd18..b4fb7faa1f 100644
--- a/lib/spack/spack/cmd/extensions.py
+++ b/lib/spack/spack/cmd/extensions.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import argparse
+import sys
import llnl.util.tty as tty
from llnl.util.tty.colify import colify
@@ -21,6 +22,8 @@ level = "long"
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'])
subparser.add_argument('-d', '--deps', action='store_true',
help='output dependencies along with found specs')
@@ -42,7 +45,19 @@ def setup_parser(subparser):
def extensions(parser, args):
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
spec = cmd.parse_specs(args.spec)
diff --git a/lib/spack/spack/test/cmd/extensions.py b/lib/spack/spack/test/cmd/extensions.py
index 505573a7bc..7fc56593eb 100644
--- a/lib/spack/spack/test/cmd/extensions.py
+++ b/lib/spack/spack/test/cmd/extensions.py
@@ -69,6 +69,11 @@ def test_extensions(mock_packages, python_database, capsys):
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):
with pytest.raises(SpackCommandError):
extensions("flake8")
diff --git a/share/spack/bash/spack-completion.in b/share/spack/bash/spack-completion.in
index ca15b8dfb2..164fc5c5b3 100755
--- a/share/spack/bash/spack-completion.in
+++ b/share/spack/bash/spack-completion.in
@@ -226,7 +226,7 @@ _config_sections() {
_extensions() {
if [[ -z "${SPACK_EXTENSIONS:-}" ]]
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
SPACK_COMPREPLY="$SPACK_EXTENSIONS"
}
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index b17733e1bf..8f677adbf9 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -226,7 +226,7 @@ _config_sections() {
_extensions() {
if [[ -z "${SPACK_EXTENSIONS:-}" ]]
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
SPACK_COMPREPLY="$SPACK_EXTENSIONS"
}