Skip to content

Commit 7dc0c9c

Browse files
committed
Merge branch 'TER-496_shell_completion' into 'master'
TER-496: add shell completion to tfwrapper commands Closes TER-496 See merge request claranet/cloud/projects/terraform/tools/tfwrapper!107
2 parents 7301adf + 9e3f650 commit 7dc0c9c

9 files changed

+374
-178
lines changed

.pre-commit-config.yaml

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.0.1
4-
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
7-
- id: check-added-large-files
8-
- id: check-toml
9-
- id: check-yaml
10-
- repo: https://gitlab.com/pycqa/flake8
11-
rev: 3.9.2
12-
hooks:
13-
- id: flake8
14-
- repo: https://github.com/psf/black
15-
rev: 21.9b0
16-
hooks:
17-
- id: black
18-
- repo: https://codeberg.org/frnmst/md-toc
19-
rev: 8.0.1
20-
hooks:
21-
- id: md-toc
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.1.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
10+
- repo: https://gitlab.com/pycqa/flake8
11+
rev: 3.9.2
12+
hooks:
13+
- id: flake8
14+
additional_dependencies:
15+
- flake8-docstrings==1.6.0
16+
- repo: https://github.com/psf/black
17+
rev: 22.1.0
18+
hooks:
19+
- id: black
20+
- repo: https://codeberg.org/frnmst/md-toc
21+
rev: 8.1.1
22+
hooks:
23+
- id: md-toc

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Runtime Dependencies](#runtime-dependencies)
1717
- [Recommended setup](#recommended-setup)
1818
- [Installation](#installation)
19+
- [Setup command-line completion](#setup-command-line-completion)
1920
- [Upgrade from tfwrapper v7 or older](#upgrade-from-tfwrapper-v7-or-older)
2021
- [Required files](#required-files)
2122
- [Configuration](#configuration)
@@ -38,6 +39,7 @@
3839
- [Stack path](#stack-path)
3940
- [Development](#development)
4041
- [Tests](#tests)
42+
- [Debug command-line completion](#debug-command-line-completion)
4143
- [Python code formatting](#python-code-formatting)
4244
- [Checks](#checks)
4345
- [README TOC](#readme-toc)
@@ -57,6 +59,7 @@
5759
- Azure credentials loading (both Service Principal or User)
5860
- GCP and GKE user ADC support
5961
- Plugins caching
62+
- Tab completion
6063

6164
## Drawbacks
6265

@@ -103,6 +106,18 @@ With zsh, you need to escape brackets:
103106
pipx install 'claranet-tfwrapper[azure]'
104107
```
105108

109+
## Setup command-line completion
110+
111+
Add the following to your shell's interactive configuration file, e.g. `.bashrc` for bash:
112+
113+
```bash
114+
eval "$(register-python-argcomplete tfwrapper -e tfwrapper)"
115+
```
116+
117+
You can then press the completion key (usually `Tab ↹`) twice to get your partially typed `tfwrapper` commands completed.
118+
119+
Note: the `-e tfwrapper` parameter adds an suffix to the defined `_python_argcomplete` function to avoid clashes with other packages (see https://github.com/kislyuk/argcomplete/issues/310#issuecomment-697168326 for context).
120+
106121
## Upgrade from tfwrapper v7 or older
107122

108123
If you used versions of the wrapper older than v8, there is not much to do when upgrading to v8
@@ -623,6 +638,14 @@ All new code contributions should come with unit and/or integrations tests.
623638

624639
To run those tests locally, use [tox](https://github.com/tox-dev/tox).
625640

641+
## Debug command-line completion
642+
643+
You can get verbose debugging information for `argcomplete` by defining the following environment variable:
644+
645+
```bash
646+
export _ARC_DEBUG=1
647+
```
648+
626649
## Python code formatting
627650

628651
Our code is formatted with [black](https://github.com/psf/black/).

poetry.lock

+2-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ azure-cli-core = {version = "^2.30.0", optional = true}
4343
azure-common = {version = "^1.1.27", optional = true}
4444
azure-mgmt-storage = {version = "^18.0.0", optional = true}
4545
msrestazure = {version = "^0.6.4", optional = true}
46+
argcomplete = "<2.0"
4647

4748
[tool.poetry.extras]
4849
azure = [

0 commit comments

Comments
 (0)