command: autocomplete data for "terraform init"

This commit is contained in:
Martin Atkins 2017-09-25 18:09:43 -07:00
parent 82fefbc599
commit 2ed9aa6077
1 changed files with 25 additions and 0 deletions

View File

@ -7,6 +7,8 @@ import (
"sort"
"strings"
"github.com/posener/complete"
"github.com/hashicorp/go-getter"
multierror "github.com/hashicorp/go-multierror"
@ -452,6 +454,29 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
return nil
}
func (c *InitCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictDirs("")
}
func (c *InitCommand) AutocompleteFlags() complete.Flags {
return complete.Flags{
"-backend": completePredictBoolean,
"-backend-config": complete.PredictFiles("*.tfvars"), // can also be key=value, but we can't "predict" that
"-force-copy": complete.PredictNothing,
"-from-module": completePredictModuleSource,
"-get": completePredictBoolean,
"-get-plugins": completePredictBoolean,
"-input": completePredictBoolean,
"-lock": completePredictBoolean,
"-lock-timeout": complete.PredictAnything,
"-no-color": complete.PredictNothing,
"-plugin-dir": complete.PredictDirs(""),
"-reconfigure": complete.PredictNothing,
"-upgrade": completePredictBoolean,
"-verify-plugins": completePredictBoolean,
}
}
func (c *InitCommand) Help() string {
helpText := `
Usage: terraform init [options] [DIR]