find: add --hashes
shortcut for piping to other commands (#38663)
People frequently ask us how to pipe `spack find` output to other commands, and we tell them to do things like this: ```console $ spack find --format "/{hash}" | spack uninstall -ay ``` Sometimes users don't know about hash references and come up with potentially ambiguous formulations like this: ```console spack find --format {name}@{version}%{compiler} | spack uninstall -ay ``` Since this is a common enough thing to want to do, and to make it more obvious how, this PR adds a `-H` / `--hashes` as a shortcut, so you can now just do: ```console spack find -H | spack uninstall -ay ```
This commit is contained in:
parent
27c62b981a
commit
757f8ae59c
2 changed files with 9 additions and 1 deletions
|
@ -30,6 +30,14 @@ def setup_parser(subparser):
|
||||||
default=None,
|
default=None,
|
||||||
help="output specs with the specified format string",
|
help="output specs with the specified format string",
|
||||||
)
|
)
|
||||||
|
format_group.add_argument(
|
||||||
|
"-H",
|
||||||
|
"--hashes",
|
||||||
|
action="store_const",
|
||||||
|
dest="format",
|
||||||
|
const="{/hash}",
|
||||||
|
help="same as '--format {/hash}'; use with xargs or $()",
|
||||||
|
)
|
||||||
format_group.add_argument(
|
format_group.add_argument(
|
||||||
"--json",
|
"--json",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ _spack_fetch() {
|
||||||
_spack_find() {
|
_spack_find() {
|
||||||
if $list_options
|
if $list_options
|
||||||
then
|
then
|
||||||
SPACK_COMPREPLY="-h --help --format --json -d --deps -p --paths --groups --no-groups -l --long -L --very-long -t --tag -c --show-concretized -f --show-flags --show-full-compiler -x --explicit -X --implicit -u --unknown -m --missing -v --variants --loaded -M --only-missing --deprecated --only-deprecated -N --namespace --start-date --end-date"
|
SPACK_COMPREPLY="-h --help --format -H --hashes --json -d --deps -p --paths --groups --no-groups -l --long -L --very-long -t --tag -c --show-concretized -f --show-flags --show-full-compiler -x --explicit -X --implicit -u --unknown -m --missing -v --variants --loaded -M --only-missing --deprecated --only-deprecated -N --namespace --start-date --end-date"
|
||||||
else
|
else
|
||||||
_installed_packages
|
_installed_packages
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue