diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2023-07-10 00:43:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 09:43:37 +0200 |
commit | 757f8ae59ca841ce75a4b452bb3092b0a80e73cd (patch) | |
tree | f8fabc73c9c90402f0cb80972399bc26853f55ea /lib | |
parent | 27c62b981ab534a67362a1b7c4037282521f0f8b (diff) | |
download | spack-757f8ae59ca841ce75a4b452bb3092b0a80e73cd.tar.gz spack-757f8ae59ca841ce75a4b452bb3092b0a80e73cd.tar.bz2 spack-757f8ae59ca841ce75a4b452bb3092b0a80e73cd.tar.xz spack-757f8ae59ca841ce75a4b452bb3092b0a80e73cd.zip |
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
```
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/find.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py index f7bd56db19..15ea5c7709 100644 --- a/lib/spack/spack/cmd/find.py +++ b/lib/spack/spack/cmd/find.py @@ -31,6 +31,14 @@ def setup_parser(subparser): 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( "--json", action="store_true", default=False, |