style: clean up and restructure spack style command

This consolidates code across tools in `spack style` so that each
`run_<tool>` function can be called indirecty through a dictionary
of handlers, and os that checks like finding the executable for the
tool can be shared across commands.

- [x] rework `spack style` to use decorators to register tools
- [x] define tool order in one place in `spack style`
- [x] fix python 2/3 issues to Get `isort` checks working
- [x] make isort error regex more robust across versions
- [x] remove unused output option
- [x] change vestigial `TRAVIS_BRANCH` to `GITHUB_BASE_REF`
- [x] update completion
This commit is contained in:
Todd Gamblin
2021-07-04 01:53:02 -07:00
parent b5d2c30d26
commit 24a4d81097
3 changed files with 79 additions and 95 deletions

View File

@@ -18,7 +18,7 @@
check_dependencies flake8 mypy
# verify that the code style is correct
spack style
spack style --root-relative
# verify that the license headers are present
spack license verify

View File

@@ -978,7 +978,7 @@ _spack_find() {
_spack_flake8() {
if $list_options
then
SPACK_COMPREPLY="-h --help -b --base -a --all -o --output -r --root-relative -U --no-untracked --no-flake8 --no-mypy --black"
SPACK_COMPREPLY="-h --help -b --base -a --all -r --root-relative -U --no-untracked -f --fix --no-isort --no-flake8 --no-mypy --black"
else
SPACK_COMPREPLY=""
fi
@@ -1584,7 +1584,7 @@ _spack_stage() {
_spack_style() {
if $list_options
then
SPACK_COMPREPLY="-h --help -b --base -a --all -o --output -r --root-relative -U --no-untracked --no-flake8 --no-mypy --black"
SPACK_COMPREPLY="-h --help -b --base -a --all -r --root-relative -U --no-untracked -f --fix --no-isort --no-flake8 --no-mypy --black"
else
SPACK_COMPREPLY=""
fi