本文整理汇总了Golang中github.com/maruel/subcommands.Application.GetErr方法的典型用法代码示例。如果您正苦于以下问题:Golang Application.GetErr方法的具体用法?Golang Application.GetErr怎么用?Golang Application.GetErr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/maruel/subcommands.Application
的用法示例。
在下文中一共展示了Application.GetErr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例8: 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
}