-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.go
37 lines (30 loc) · 677 Bytes
/
gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"
"github.com/spf13/cobra"
)
func genTest(cmd *cobra.Command, filename string) {
out := new(bytes.Buffer)
cobra.GenCompletion(cmd, out)
outFile, err := os.Create(filename)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer outFile.Close()
_, err = outFile.Write(out.Bytes())
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func main() {
kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard)
genTest(kubectl, "/tmp/kubectl")
//osc := cli.NewCommandCLI("osc", "osc")
//genTest(osc, "/tmp/osc")
}