Esempio n. 1
0
func main() {
	// use os.Args instead of "flags" because "flags" will mess up the man pages!
	path := "contrib/completions/bash/"
	if len(os.Args) == 2 {
		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 := OutDir(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
		os.Exit(1)
	}

	flag.CommandLine.VisitAll(func(f *flag.Flag) {
		fmt.Fprintf(os.Stderr, "warning: ignoring flag %q which is in the global set\n", f.Name)
	})
	flag.CommandLine = flag.NewFlagSet("empty", flag.ContinueOnError)

	outFile_openshift := outDir + "openshift"
	openshift := openshift.NewCommandOpenShift("openshift")
	openshift.GenBashCompletionFile(outFile_openshift)

	outFile_osc := outDir + "oc"
	out := os.Stdout
	oc := cli.NewCommandCLI("oc", "openshift cli", &bytes.Buffer{}, out, ioutil.Discard)
	oc.GenBashCompletionFile(outFile_osc)

	outFile_osadm := outDir + "oadm"
	oadm := admin.NewCommandAdmin("oadm", "openshift admin", ioutil.Discard)
	oadm.GenBashCompletionFile(outFile_osadm)
}
Esempio n. 2
0
func main() {
	// use os.Args instead of "flags" because "flags" will mess up the man pages!
	path := "rel-eng/completions/bash/"
	if len(os.Args) == 2 {
		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 := OutDir(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
		os.Exit(1)
	}
	outFile_openshift := outDir + "openshift"
	openshift := openshift.NewCommandOpenShift("openshift")
	openshift.GenBashCompletionFile(outFile_openshift)

	outFile_osc := outDir + "oc"
	oc := cli.NewCommandCLI("oc", "openshift cli")
	oc.GenBashCompletionFile(outFile_osc)

	outFile_osadm := outDir + "oadm"
	oadm := admin.NewCommandAdmin("oadm", "openshift admin", ioutil.Discard)
	oadm.GenBashCompletionFile(outFile_osadm)
}
func main() {
	errors := []error{}

	oc := openshift.NewCommandOpenShift("openshift")
	result := cmdsanity.CheckCmdTree(oc, cmdsanity.AllCmdChecks, skip)
	errors = append(errors, result...)

	if len(errors) > 0 {
		for i, err := range errors {
			fmt.Fprintf(os.Stderr, "%d. %s\n\n", i+1, err)
		}
		os.Exit(1)
	}

	fmt.Fprintln(os.Stdout, "Congrats, CLI looks good!")
}
Esempio n. 4
0
func main() {
	if len(os.Args) < 3 {
		fmt.Fprintf(os.Stderr, "Root command not specified (oc | oadm | openshift).\n")
		os.Exit(1)
	}

	if strings.HasSuffix(os.Args[2], "oc") {
		genCmdMan("oc", cli.NewCommandCLI("oc", "oc", &bytes.Buffer{}, os.Stdout, ioutil.Discard))
	} else if strings.HasSuffix(os.Args[2], "openshift") {
		genCmdMan("openshift", openshift.NewCommandOpenShift("openshift"))
	} else if strings.HasSuffix(os.Args[2], "oadm") {
		genCmdMan("oadm", admin.NewCommandAdmin("oadm", "oadm", &bytes.Buffer{}, os.Stdout, ioutil.Discard))
	} else {
		fmt.Fprintf(os.Stderr, "Root command not specified (os | oadm | openshift).")
		os.Exit(1)
	}
}