mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
doc/bash completions autogeneration directory helper
This commit is contained in:
@@ -20,39 +20,28 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/cmd/genutils"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"
|
||||
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// use os.Args instead of "flags" because "flags" will mess up the man pages!
|
||||
outDir := "contrib/completions/bash/"
|
||||
path := "contrib/completions/bash/"
|
||||
if len(os.Args) == 2 {
|
||||
outDir = os.Args[1]
|
||||
path = os.Args[1]
|
||||
} else if len(os.Args) > 2 {
|
||||
fmt.Fprintf(os.Stderr, "usage: %s [output directory]\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
outDir, err := filepath.Abs(outDir)
|
||||
outDir, err := genutils.OutDir(path)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
stat, err := os.Stat(outDir)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "output directory %s does not exist\n", outDir)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !stat.IsDir() {
|
||||
fmt.Fprintf(os.Stderr, "output directory %s is not a directory\n", outDir)
|
||||
os.Exit(1)
|
||||
}
|
||||
outFile := outDir + "/kubectl"
|
||||
outFile := outDir + "kubectl"
|
||||
|
||||
//TODO os.Stdin should really be something like ioutil.Discard, but a Reader
|
||||
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
|
||||
|
Reference in New Issue
Block a user