Add basic autocompletion (#3223)

* Add basic autocompletion

* Add autocomplete to some common commands

* Autocomplete the generate-root flags

* Add information about autocomplete to the docs
This commit is contained in:
Brian Kassouf
2017-08-24 15:23:40 -07:00
committed by GitHub
parent f526091a7d
commit 41db07530a
13 changed files with 240 additions and 7 deletions

View File

@@ -23,6 +23,7 @@ import (
colorable "github.com/mattn/go-colorable"
log "github.com/mgutz/logxi/v1"
testing "github.com/mitchellh/go-testing-interface"
"github.com/posener/complete"
"google.golang.org/grpc/grpclog"
@@ -1200,6 +1201,20 @@ General Options:
return strings.TrimSpace(helpText)
}
func (c *ServerCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
}
func (c *ServerCommand) AutocompleteFlags() complete.Flags {
return complete.Flags{
"-config": complete.PredictOr(complete.PredictFiles("*.hcl"), complete.PredictFiles("*.json")),
"-dev": complete.PredictNothing,
"-dev-root-token-id": complete.PredictNothing,
"-dev-listen-address": complete.PredictNothing,
"-log-level": complete.PredictSet("trace", "debug", "info", "warn", "err"),
}
}
// MakeShutdownCh returns a channel that can be used for shutdown
// notifications for commands. This channel will send a message for every
// SIGINT or SIGTERM received.