func TestMainHelp(t *testing.T) { t.Parallel() a := subcommandstest.MakeAppMock(t, application) args := []string{"help"} r := subcommands.Run(a, args) ut.AssertEqual(t, 0, r) a.CheckBuffer(true, false) }
func RunApplication() { //defer FlushLog() mgollective := &subcommands.DefaultApplication{ Name: "mgo", Title: "mgollective", Commands: append(commands, subcommands.CmdHelp), } subcommands.Run(mgollective, os.Args[1:]) }
func TestSleep(t *testing.T) { defer mockStdout(t)() // If running with "go test -v", the following log entry will be printed: // utiltest.go:132: 2010/01/02 03:04:05 Simulating sleeping for 1s. out := ut.NewWriter(t) defer out.Close() log.SetOutput(out) ut.AssertEqual(t, 0, subcommands.Run(application, []string{"sleep", "-duration", "1"})) assertStdout(t, "") }
func main() { opts := auth.Options{Logger: gologger.Get()} application := &subcommands.DefaultApplication{ Name: "auth", Title: "Chrome Infra Authentication tool", Commands: []*subcommands.Command{ subcommands.CmdHelp, authcli.SubcommandInfo(opts, "info"), authcli.SubcommandLogin(opts, "login"), authcli.SubcommandLogout(opts, "logout"), }, } os.Exit(subcommands.Run(application, nil)) }
func TestBadCommand(t *testing.T) { app := &subcommands.DefaultApplication{ Name: "name", Title: "doc", Commands: []*subcommands.Command{ subcommands.CmdHelp, }, } a := MakeAppMock(t, app) args := []string{"non_existing_command"} r := subcommands.Run(a, args) ut.AssertEqual(t, r, 2) a.CheckBuffer(false, true) }
func TestHelp(t *testing.T) { app := &subcommands.DefaultApplication{ Name: "name", Title: "doc", Commands: []*subcommands.Command{ subcommands.CmdHelp, }, } a := MakeAppMock(t, app) args := []string{"help"} r := subcommands.Run(a, args) ut.AssertEqual(t, r, 0) a.CheckBuffer(true, false) }
func main() { log.SetFlags(log.Lmicroseconds) os.Exit(subcommands.Run(application, nil)) }
func TestGreet(t *testing.T) { defer mockStdout(t)() ut.AssertEqual(t, 0, subcommands.Run(application, []string{"greet", "active tester"})) assertStdout(t, "Hi active tester!\n") }
func main() { log.SetFlags(log.Lmicroseconds) d := &dumbapp{application, log.New(application.GetErr(), "", log.LstdFlags|log.Lmicroseconds)} os.Exit(subcommands.Run(d, nil)) }
func main() { os.Exit(subcommands.Run(application, nil)) }
func main() { os.Exit(subcommands.Run(application, os.Args[1:])) }
func main() { os.Exit(subcommands.Run(application, fixFlagsPosition(os.Args[1:]))) }
func main() { subcommands.KillStdLog() s := &sample{application, log.New(ioutil.Discard, "", log.LstdFlags|log.Lmicroseconds)} os.Exit(subcommands.Run(s, nil)) }
func (a *DumbcasAppMock) Run(args []string, expected int) { a.GetLog().Printf("%s", args) returncode := subcommands.Run(a, args) ut.AssertEqual(a, expected, returncode) }
func (c *askRun) Run(a subcommands.Application, args []string, env subcommands.Env) int { d := a.(SampleApplication) // Create an inner application. return subcommands.Run(askApplication{d}, args) }