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 }
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 }
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 }
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 }
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 }
func (c *sleepRun) Run(a subcommands.Application, args []string, env subcommands.Env) int { if len(args) != 0 { fmt.Fprintf(os.Stderr, "%s: Unsupported arguments.\n", a.GetName()) return 1 } if c.duration <= 0 { fmt.Fprintf(os.Stderr, "%s: -duration is required.\n", a.GetName()) return 1 } log.Printf("Simulating sleeping for %ds.\n", c.duration) return 0 }
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 }
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 }
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 }
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 }