mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
main: enable basic subcommand autocomplete
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
This commit is contained in:
7
main.go
7
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -134,6 +135,7 @@ func wrappedMain() int {
|
||||
defer plugin.CleanupClients()
|
||||
|
||||
// Get the command line args.
|
||||
binName := filepath.Base(os.Args[0])
|
||||
args := os.Args[1:]
|
||||
|
||||
// Build the CLI so far, we do this so we can query the subcommand.
|
||||
@@ -175,10 +177,15 @@ func wrappedMain() int {
|
||||
// Rebuild the CLI with any modified args.
|
||||
log.Printf("[INFO] CLI command args: %#v", args)
|
||||
cliRunner = &cli.CLI{
|
||||
Name: binName,
|
||||
Args: args,
|
||||
Commands: Commands,
|
||||
HelpFunc: helpFunc,
|
||||
HelpWriter: os.Stdout,
|
||||
|
||||
Autocomplete: true,
|
||||
AutocompleteInstall: "install-autocomplete",
|
||||
AutocompleteUninstall: "uninstall-autocomplete",
|
||||
}
|
||||
|
||||
// Pass in the overriding plugin paths from config
|
||||
|
||||
Reference in New Issue
Block a user