func main() { c := commander.Commander{ Name: "cockroach", Commands: []*commander.Command{ server.CmdInit, server.CmdGetZone, server.CmdLsZones, server.CmdRmZone, server.CmdSetZone, server.CmdStart, }, } if err := c.Run(os.Args[1:]); err != nil { os.Exit(1) } }
func main() { // Instruct Go to use all CPU cores. // TODO(spencer): this may be excessive and result in worse // performance. We should keep an eye on this as we move to // production workloads. numCPU := runtime.NumCPU() runtime.GOMAXPROCS(numCPU) log.V(1).Infof("running using %d processor cores", numCPU) c := commander.Commander{ Name: "cockroach", Commands: []*commander.Command{ server.CmdInit, server.CmdGetZone, server.CmdLsZones, server.CmdRmZone, server.CmdSetZone, server.CmdStart, &commander.Command{ UsageLine: "listparams", Short: "list all available parameters and their default values", Long: ` List all available parameters and their default values. Note that parameter parsing stops after the first non- option after the command name. Hence, the options need to precede any additional arguments, cockroach <command> [options] [arguments].`, Run: func(cmd *commander.Command, args []string) { flag.CommandLine.PrintDefaults() }, }, }, } if len(os.Args) == 1 { os.Args = append(os.Args, "help") } if err := c.Run(os.Args[1:]); err != nil { log.Errorf("Failed running command \"%s\": %v\n", os.Args[1:], err) os.Exit(1) } }
func main() { defer glog.Flush() c := commander.Commander{ Name: "ezgliding", Commands: []*commander.Command{ cli.CmdAirfieldGet, cli.CmdAirfieldPut, cli.CmdAirspaceGet, cli.CmdFlightGet, cli.CmdWaypointGet, cli.CmdWaypointPut, cli.CmdWeb, }, } if len(os.Args) == 1 { os.Args = append(os.Args, "help") } if err := c.Run(os.Args[1:]); err != nil { glog.Errorf("Failed running command %q: %v", os.Args[1:], err) exit(-1) } }
func main() { // Instruct Go to use all CPU cores. // TODO(spencer): this may be excessive and result in worse // performance. We should keep an eye on this as we move to // production workloads. numCPU := runtime.NumCPU() runtime.GOMAXPROCS(numCPU) rand.Seed(util.NewPseudoSeed()) log.V(1).Infof("running using %d processor cores", numCPU) c := commander.Commander{ Name: "cockroach", Commands: []*commander.Command{ cli.CmdInit, cli.CmdGetZone, cli.CmdLsZones, cli.CmdRmZone, cli.CmdSetZone, cli.CmdStart, { UsageLine: "listparams", Short: "list all available parameters and their default values", Long: ` List all available parameters and their default values. Note that parameter parsing stops after the first non- option after the command name. Hence, the options need to precede any additional arguments, cockroach <command> [options] [arguments].`, Run: func(cmd *commander.Command, args []string) { flag.CommandLine.PrintDefaults() }, }, { UsageLine: "version", Short: "output version information", Long: ` Output build version information. `, Run: func(cmd *commander.Command, args []string) { info := util.GetBuildInfo() w := &tabwriter.Writer{} w.Init(os.Stdout, 2, 1, 2, ' ', 0) fmt.Fprintf(w, "Build Vers: %s\n", info.Vers) fmt.Fprintf(w, "Build Tag: %s\n", info.Tag) fmt.Fprintf(w, "Build Time: %s\n", info.Time) fmt.Fprintf(w, "Build Deps:\n\t%s\n", strings.Replace(strings.Replace(info.Deps, " ", "\n\t", -1), ":", "\t", -1)) w.Flush() }, }, }, } cli.InitFlags(cli.Context) if len(os.Args) == 1 { os.Args = append(os.Args, "help") } if err := c.Run(os.Args[1:]); err != nil { log.Fatalf("Failed running command %q: %v\n", os.Args[1:], err) } }