spack/share/spack/qa
Todd Gamblin d991ec90e3
new command: spack pkg grep to search package files (#34388)
It's very common for us to tell users to grep through the existing Spack packages to
find examples of what they want, and it's also very common for package developers to do
it. Now, searching packages is even easier.

`spack pkg grep` runs grep on all `package.py` files in repos known to Spack. It has no
special options other than the search string; all options passed to it are forwarded
along to `grep`.

```console
> spack pkg grep --help
usage: spack pkg grep [--help] ...

positional arguments:
  grep_args  arguments for grep

options:
  --help     show this help message and exit
```

```console
> spack pkg grep CMakePackage | head -3
/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/3dtk/package.py:class _3dtk(CMakePackage):
/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/abseil-cpp/package.py:class AbseilCpp(CMakePackage):
/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/accfft/package.py:class Accfft(CMakePackage, CudaPackage):
```

```console
> spack pkg grep -Eho '(\S*)\(PythonPackage\)' | head -3
AwsParallelcluster(PythonPackage)
Awscli(PythonPackage)
Bueno(PythonPackage)
```

## Return Value

This retains the return value semantics of `grep`:
* 0  for found,
* 1  for not found
* >1 for error

## Choosing a `grep`

You can set the ``SPACK_GREP`` environment variable to choose the ``grep``
executable this command should use.
2022-12-09 10:07:54 -08:00
..
configuration warn about removal of deprecated format strings (#34101) 2022-11-28 10:03:49 -08:00
bashcov Use kcov from official Ubuntu 20.04 repository (#25385) 2021-08-19 14:03:10 -07:00
completion-test.sh new command: spack pkg grep to search package files (#34388) 2022-12-09 10:07:54 -08:00
flake8_formatter.py black: fix style check package and flake8 formatting for black 2022-07-31 13:29:20 -07:00
run-build-tests Update copyright year to 2022 2022-01-14 22:50:21 -08:00
run-shell-tests Remove recursive symbolic link in lib/spack/docs from git repository (#33483) 2022-10-25 12:27:13 +02:00
run-style-tests Update copyright year to 2022 2022-01-14 22:50:21 -08:00
run-unit-tests Let pytest-cov create the xml directly (#33619) 2022-11-01 19:04:45 +01:00
setup-env-test.csh Update copyright year to 2022 2022-01-14 22:50:21 -08:00
setup-env-test.fish Don't set LD_LIBRARY_PATH by default on Linux (#28354) 2022-08-11 09:33:08 -05:00
setup-env-test.sh bugfix: spack load shell test can fail on macos (#34419) 2022-12-09 10:36:54 +00:00
setup.sh Update copyright year to 2022 2022-01-14 22:50:21 -08:00
setup_spack_installer.ps1 Windows: reenable unit tests (#33385) 2022-12-09 13:27:46 +00:00
test-env-cfg.sh Update copyright year to 2022 2022-01-14 22:50:21 -08:00
test-framework.sh Update copyright year to 2022 2022-01-14 22:50:21 -08:00
validate_last_exit.ps1 Windows: reenable unit tests (#33385) 2022-12-09 13:27:46 +00:00
vcvarsall.ps1 Add Github Actions for Windows (#24504) 2022-03-17 09:01:01 -07:00
windows_test_setup.ps1 Windows: reenable unit tests (#33385) 2022-12-09 13:27:46 +00:00