Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI autocomplete #16176

Merged
merged 8 commits into from
Sep 26, 2017
Merged

CLI autocomplete #16176

merged 8 commits into from
Sep 26, 2017

Conversation

apparentlymart
Copy link
Contributor

This set of changes enables tab-completion for bash and zsh users, building on the mechanisms provided by the cli package, which in turn delegates to the complete package.

By turning on autocomplete, we get autocomplete of the sub-command names themselves for free.

We then need to augment each command object with some additional methods to define the expected options and arguments. This changeset does this for terraform init and for the terraform workspace ... family of commands. We can build out comprehensive support across all the commands over time in separate PRs.

The CLI package has automatic support for shell autocomplete (bash and
zsh, at time of writing) for subcommands, so all we need to do here is
just opt into it.

Users can install this into their shells by running:
    terraform -install-autocomplete
We use boolean flags and module sources in a lot of places, so we'll
define global predictors for these which we can use across many commands.
The predictors built in to the "complete" package assume that the same
type of argument is repeated indefinitely, but most Terraform commands
don't work like that, so this helper allows us to define a sequence of
predictors that apply to each argument in turn.
This helper is a Predictor for the "complete" package that tries to
auto-complete workspace names from the current backend, if it's
initialized and operable.
Shell tab completion for all of the subcommands under
"terraform workspace", providing the appropriate kind of auto-complete for
each argument, along with completion for for any flags.
@apparentlymart apparentlymart merged commit 2c782e6 into master Sep 26, 2017
@apparentlymart apparentlymart deleted the f-cli-autocomplete branch February 5, 2018 19:17
@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants