spack/share/spack
Adam J. Stewart 11f2b61261 Use spack commands --format=bash to generate shell completion (#14393)
This PR adds a `--format=bash` option to `spack commands` to
auto-generate the Bash programmable tab completion script. It can be
extended to work for other shells.

Progress:

- [x] Fix bug in superclass initialization in `ArgparseWriter`
- [x] Refactor `ArgparseWriter` (see below)
- [x] Ensure that output of old `--format` options remains the same
- [x] Add `ArgparseCompletionWriter` and `BashCompletionWriter`
- [x] Add `--aliases` option to add command aliases
- [x] Standardize positional argument names
- [x] Tests for `spack commands --format=bash` coverage
- [x] Tests to make sure `spack-completion.bash` stays up-to-date
- [x] Tests for `spack-completion.bash` coverage
- [x] Speed up `spack-completion.bash` by caching subroutine calls

This PR also necessitates a significant refactoring of
`ArgparseWriter`. Previously, `ArgparseWriter` was mostly a single
`_write` method which handled everything from extracting the information
we care about from the parser to formatting the output. Now, `_write`
only handles recursion, while the information extraction is split into a
separate `parse` method, and the formatting is handled by `format`. This
allows subclasses to completely redefine how the format will appear
without overriding all of `_write`.

Co-Authored-by: Todd Gamblin <tgamblin@llnl.gov>
2020-01-22 21:31:12 -08:00
..
bash Use spack commands --format=bash to generate shell completion (#14393) 2020-01-22 21:31:12 -08:00
csh copyright: update copyright dates for 2020 (#14328) 2019-12-30 22:36:56 -08:00
docker copyright: update copyright dates for 2020 (#14328) 2019-12-30 22:36:56 -08:00
docs/docker/module-file-tutorial copyright: update copyright dates for 2020 (#14328) 2019-12-30 22:36:56 -08:00
logo add artisanal handcrafted SVG Spack logo. (#6165) 2017-11-06 22:42:16 -08:00
qa Use spack commands --format=bash to generate shell completion (#14393) 2020-01-22 21:31:12 -08:00
templates copyright: update copyright dates for 2020 (#14328) 2019-12-30 22:36:56 -08:00
setup-env.csh copyright: update copyright dates for 2020 (#14328) 2019-12-30 22:36:56 -08:00
setup-env.sh stop word splitting from leaking out of setup-env (#14472) 2020-01-14 15:32:57 -08:00
spack-completion.bash Use spack commands --format=bash to generate shell completion (#14393) 2020-01-22 21:31:12 -08:00