Merge pull request #2043 from pwittrock/master

Fix various cmd/config issues
This commit is contained in:
Kubernetes Prow Robot
2020-01-08 11:23:41 -08:00
committed by GitHub
35 changed files with 661 additions and 143 deletions

View File

@@ -6,35 +6,17 @@ package main
import (
"os"
"path/filepath"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/cmd/config/complete"
"sigs.k8s.io/kustomize/kustomize/v3/internal/commands"
)
func main() {
cmd := commands.NewDefaultCommand()
completion(cmd)
complete.Complete(cmd).Complete("kustomize")
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
os.Exit(0)
}
// completion performs shell completion if kustomize is being called to provide
// shell completion commands.
func completion(cmd *cobra.Command) {
// bash shell completion passes the command name as the first argument
// do this after configuring cmd so it has all the subcommands
if len(os.Args) > 1 {
// use the base name in case kustomize is called with an absolute path
name := filepath.Base(os.Args[1])
if name == "kustomize" {
// complete calls kustomize with itself as an argument
complete.Complete(cmd).Complete("kustomize")
os.Exit(0)
}
}
}