本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/cli.NewCommandCLI函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCommandCLI函数的具体用法?Golang NewCommandCLI怎么用?Golang NewCommandCLI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCommandCLI函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
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)
}
开发者ID:richm,项目名称:origin,代码行数:34,代码来源:gen_openshift_bash_comp.go
示例2: main
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)
}
开发者ID:cjnygard,项目名称:origin,代码行数:27,代码来源:gen_openshift_bash_comp.go
示例3: CommandFor
// CommandFor returns the appropriate command for this base name,
// or the global OpenShift command
func CommandFor(basename string) *cobra.Command {
var cmd *cobra.Command
in, out, errout := os.Stdin, os.Stdout, os.Stderr
// Make case-insensitive and strip executable suffix if present
if runtime.GOOS == "windows" {
basename = strings.ToLower(basename)
basename = strings.TrimSuffix(basename, ".exe")
}
switch basename {
case "openshift-router":
cmd = irouter.NewCommandTemplateRouter(basename)
case "openshift-f5-router":
cmd = irouter.NewCommandF5Router(basename)
case "openshift-deploy":
cmd = deployer.NewCommandDeployer(basename)
case "openshift-recycle":
cmd = recycle.NewCommandRecycle(basename, out)
case "openshift-sti-build":
cmd = builder.NewCommandSTIBuilder(basename)
case "openshift-docker-build":
cmd = builder.NewCommandDockerBuilder(basename)
case "oc", "osc":
cmd = cli.NewCommandCLI(basename, basename, in, out, errout)
case "oadm", "osadm":
cmd = admin.NewCommandAdmin(basename, basename, out, errout)
case "kubectl":
cmd = cli.NewCmdKubectl(basename, out)
case "kube-apiserver":
cmd = kubernetes.NewAPIServerCommand(basename, basename, out)
case "kube-controller-manager":
cmd = kubernetes.NewControllersCommand(basename, basename, out)
case "kubelet":
cmd = kubernetes.NewKubeletCommand(basename, basename, out)
case "kube-proxy":
cmd = kubernetes.NewProxyCommand(basename, basename, out)
case "kube-scheduler":
cmd = kubernetes.NewSchedulerCommand(basename, basename, out)
case "kubernetes":
cmd = kubernetes.NewCommand(basename, basename, out)
case "origin", "atomic-enterprise":
cmd = NewCommandOpenShift(basename)
default:
cmd = NewCommandOpenShift("openshift")
}
if cmd.UsageFunc() == nil {
templates.ActsAsRootCommand(cmd, []string{"options"})
}
flagtypes.GLog(cmd.PersistentFlags())
return cmd
}
开发者ID:Xmagicer,项目名称:origin,代码行数:57,代码来源:openshift.go
示例4: NewCommandOpenShift
// NewCommandOpenShift creates the standard OpenShift command
func NewCommandOpenShift(name string) *cobra.Command {
in, out, errout := os.Stdin, os.Stdout, os.Stderr
product := "Origin"
switch name {
case "openshift":
product = "OpenShift"
case "atomic-enterprise":
product = "Atomic"
}
root := &cobra.Command{
Use: name,
Short: "Build, deploy, and manage your cloud applications",
Long: fmt.Sprintf(openshiftLong, name, product),
Run: cmdutil.DefaultSubCommandRun(out),
}
startAllInOne, _ := start.NewCommandStartAllInOne(name, out)
root.AddCommand(startAllInOne)
root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", out))
root.AddCommand(cli.NewCommandCLI("cli", name+" cli", in, out, errout))
root.AddCommand(cli.NewCmdKubectl("kube", out))
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(version.NewVersionCommand(name))
// infra commands are those that are bundled with the binary but not displayed to end users
// directly
infra := &cobra.Command{
Use: "infra", // Because this command exposes no description, it will not be shown in help
}
infra.AddCommand(
irouter.NewCommandTemplateRouter("router"),
irouter.NewCommandF5Router("f5-router"),
deployer.NewCommandDeployer("deploy"),
builder.NewCommandSTIBuilder("sti-build"),
builder.NewCommandDockerBuilder("docker-build"),
)
root.AddCommand(infra)
root.AddCommand(cmd.NewCmdOptions(out))
// TODO: add groups
templates.ActsAsRootCommand(root)
return root
}
开发者ID:kimifdw,项目名称:origin,代码行数:49,代码来源:openshift.go
示例5: main
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)
}
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:17,代码来源:gen_man.go
示例6: NewCommandOpenShift
// NewCommandOpenShift creates the standard OpenShift command
func NewCommandOpenShift(name string) *cobra.Command {
in, out, errout := os.Stdin, term.NewResponsiveWriter(os.Stdout), os.Stderr
root := &cobra.Command{
Use: name,
Short: "Build, deploy, and manage your cloud applications",
Long: fmt.Sprintf(openshiftLong, name, cmdutil.GetPlatformName(name), cmdutil.GetDistributionName(name)),
Run: kcmdutil.DefaultSubCommandRun(out),
}
f := clientcmd.New(pflag.NewFlagSet("", pflag.ContinueOnError))
startAllInOne, _ := start.NewCommandStartAllInOne(name, out, errout)
root.AddCommand(startAllInOne)
root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", in, out, errout))
root.AddCommand(cli.NewCommandCLI("cli", name+" cli", in, out, errout))
root.AddCommand(cli.NewCmdKubectl("kube", out))
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(newCompletionCommand("completion", name+" completion"))
root.AddCommand(cmd.NewCmdVersion(name, f, out, cmd.VersionOptions{PrintEtcdVersion: true, IsServer: true}))
// infra commands are those that are bundled with the binary but not displayed to end users
// directly
infra := &cobra.Command{
Use: "infra", // Because this command exposes no description, it will not be shown in help
}
infra.AddCommand(
irouter.NewCommandTemplateRouter("router"),
irouter.NewCommandF5Router("f5-router"),
deployer.NewCommandDeployer("deploy"),
recycle.NewCommandRecycle("recycle", out),
builder.NewCommandS2IBuilder("sti-build"),
builder.NewCommandDockerBuilder("docker-build"),
diagnostics.NewCommandPodDiagnostics("diagnostic-pod", out),
diagnostics.NewCommandNetworkPodDiagnostics("network-diagnostic-pod", out),
)
root.AddCommand(infra)
root.AddCommand(cmd.NewCmdOptions(out))
// TODO: add groups
templates.ActsAsRootCommand(root, []string{"options"})
return root
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:47,代码来源:openshift.go
示例7: Run
// Run executes given OpenShift CLI command verb (iow. "oc <verb>").
// This function also override the default 'stdout' to redirect all output
// to a buffer and prepare the global flags such as namespace and config path.
func (c *CLI) Run(verb string) *CLI {
out := new(bytes.Buffer)
nc := &CLI{
verb: verb,
kubeFramework: c.KubeFramework(),
adminConfigPath: c.adminConfigPath,
configPath: c.configPath,
username: c.username,
outputDir: c.outputDir,
cmd: cli.NewCommandCLI("oc", "openshift", out),
globalArgs: []string{
verb,
fmt.Sprintf("--namespace=%s", c.Namespace()),
fmt.Sprintf("--config=%s", c.configPath),
},
}
return nc.SetOutput(out)
}
开发者ID:Tlacenka,项目名称:origin,代码行数:21,代码来源:cli.go
示例8: Run
// Run executes given OpenShift CLI command verb (iow. "oc <verb>").
// This function also override the default 'stdout' to redirect all output
// to a buffer and prepare the global flags such as namespace and config path.
func (c *CLI) Run(verb string) *CLI {
in, out, errout := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
nc := &CLI{
verb: verb,
kubeFramework: c.KubeFramework(),
adminConfigPath: c.adminConfigPath,
configPath: c.configPath,
username: c.username,
outputDir: c.outputDir,
cmd: cli.NewCommandCLI("oc", "openshift", in, out, errout),
globalArgs: []string{
verb,
fmt.Sprintf("--namespace=%s", c.Namespace()),
fmt.Sprintf("--config=%s", c.configPath),
},
}
nc.stdin, nc.stdout, nc.stderr = in, out, errout
return nc.setOutput(c.stdout)
}
开发者ID:flyingfsck,项目名称:origin,代码行数:23,代码来源:cli.go
示例9: NewCommandOpenShift
// NewCommandOpenShift creates the standard OpenShift command
func NewCommandOpenShift(name string) *cobra.Command {
out := os.Stdout
root := &cobra.Command{
Use: name,
Short: "OpenShift helps you build, deploy, and manage your cloud applications",
Long: openshiftLong,
Run: cmdutil.DefaultSubCommandRun(out),
}
startAllInOne, _ := start.NewCommandStartAllInOne(name, out)
root.AddCommand(startAllInOne)
root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", out))
root.AddCommand(cli.NewCommandCLI("cli", name+" cli"))
root.AddCommand(cli.NewCmdKubectl("kube", out))
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(version.NewVersionCommand(name))
// infra commands are those that are bundled with the binary but not displayed to end users
// directly
infra := &cobra.Command{
Use: "infra", // Because this command exposes no description, it will not be shown in help
}
infra.AddCommand(
irouter.NewCommandTemplateRouter("router"),
deployer.NewCommandDeployer("deploy"),
builder.NewCommandSTIBuilder("sti-build"),
builder.NewCommandDockerBuilder("docker-build"),
gitserver.NewCommandGitServer("git-server"),
)
root.AddCommand(infra)
root.AddCommand(cmd.NewCmdOptions(out))
// TODO: add groups
templates.ActsAsRootCommand(root)
return root
}
开发者ID:cjnygard,项目名称:origin,代码行数:41,代码来源:openshift.go
示例10: main
func main() {
path := "docs/generated/"
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 := outDir + "oc_by_example_content.adoc"
cmd := cli.NewCommandCLI("oc", "openshift cli")
gendocs.GenDocs(cmd, outFile)
outFile = outDir + "oadm_by_example_content.adoc"
cmd = admin.NewCommandAdmin("oadm", "openshift admin", ioutil.Discard)
gendocs.GenDocs(cmd, outFile)
}
开发者ID:cjnygard,项目名称:origin,代码行数:23,代码来源:gen_openshift_docs.go
注:本文中的github.com/openshift/origin/pkg/cmd/cli.NewCommandCLI函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论