本文整理汇总了Golang中github.com/maruel/subcommands.Application类的典型用法代码示例。如果您正苦于以下问题:Golang Application类的具体用法?Golang Application怎么用?Golang Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Run
func (c *greetRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
if len(args) != 1 {
fmt.Fprintf(os.Stderr, "%s: Can only greet one person at a time.\n", a.GetName())
return 1
}
fmt.Printf("Hi %s!\n", args[0])
return 0
}
开发者ID:maruel,项目名称:subcommands,代码行数:8,代码来源:main.go
示例2: Run
func (c *versionRun) Run(a subcommands.Application, args []string) int {
if len(args) != 0 {
fmt.Fprintf(a.GetErr(), "%s: position arguments not expected\n", a.GetName())
return 1
}
fmt.Println(c.version)
return 0
}
开发者ID:shishkander,项目名称:luci-go,代码行数:8,代码来源:version.go
示例3: Run
func (c *greetRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
if len(args) != 1 {
fmt.Fprintf(a.GetErr(), "%s: Can only greet one person at a time.\n", a.GetName())
return 1
}
d := a.(SampleApplication)
if err := c.main(d, args[0], env["GREET_STYLE"].Value); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
开发者ID:maruel,项目名称:subcommands,代码行数:12,代码来源:greet.go
示例4: Run
func (c *askBeerRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
if len(args) != 0 {
fmt.Fprintf(a.GetErr(), "%s: Unknown arguments.\n", a.GetName())
return 1
}
d := a.(askApplication)
if err := c.main(d); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
开发者ID:maruel,项目名称:subcommands,代码行数:12,代码来源:ask_beer.go
示例5: Run
func (c *gcRun) Run(a subcommands.Application, args []string) int {
if len(args) != 0 {
fmt.Fprintf(a.GetErr(), "%s: Unsupported arguments.\n", a.GetName())
return 1
}
d := a.(DumbcasApplication)
if err := c.main(d); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
开发者ID:maruel,项目名称:dumbcas,代码行数:12,代码来源:gc.go
示例6: Run
func (c *restoreRun) Run(a subcommands.Application, args []string) int {
if len(args) != 1 {
fmt.Fprintf(a.GetErr(), "%s: Must only provide a <node>.\n", a.GetName())
return 1
}
interrupt.HandleCtrlC()
d := a.(DumbcasApplication)
if err := c.main(d, args[0]); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
开发者ID:maruel,项目名称:dumbcas,代码行数:13,代码来源:restore.go
示例7: Run
func (c *sleepRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
if len(args) != 0 {
fmt.Fprintf(a.GetErr(), "%s: Unsupported arguments.\n", a.GetName())
return 1
}
d := a.(SampleApplication)
// This main() wrapping simplifies the surfacing of errors into printing to
// stderr then exiting with 1.
if err := c.main(d, env["VERBOSE_DREAMS"].Value == "1"); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
开发者ID:maruel,项目名称:subcommands,代码行数:14,代码来源:sleep.go
示例8: Run
func (c *versionRun) Run(a subcommands.Application, args []string) int {
if len(args) != 0 {
fmt.Fprintf(a.GetErr(), "%s: Unsupported arguments.\n", a.GetName())
return 1
}
fmt.Fprintf(a.GetOut(), "0.1\n")
return 0
}
开发者ID:maruel,项目名称:dumbcas,代码行数:8,代码来源:version.go
示例9: Run
func (c *downloadRun) Run(a subcommands.Application, args []string) int {
if err := c.Parse(a, args); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
cl, err := c.defaultFlags.StartTracing()
if err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
defer cl.Close()
if err := c.main(a, args); err != nil {
fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
return 1
}
return 0
}
开发者ID:shishkander,项目名称:luci-go,代码行数:17,代码来源:download.go
注:本文中的github.com/maruel/subcommands.Application类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论