func main() { runtime.GOMAXPROCS(runtime.NumCPU()) flag.Usage = func() { fmt.Fprintln(os.Stderr, cli.HelpMessage) } flag.Parse() if flVersion { if err := cli.PrintVersion(); err != nil { log.Fatal(err) } return } if flServerMode { fullAddress := fmt.Sprintf("%v:%v", flServerAddress, flServerPort) log.Printf("Running dogestry in server mode on '%v'", fullAddress) s := server.New(fullAddress) s.ServeHttp() } else { args := flag.Args() // Allow 'help', 'version' and 'login' to not require AWS cred env vars requireEnvVars := true if len(args) == 0 || (args[0] == "help" || args[0] == "login" || args[0] == "version") { requireEnvVars = false } cfg, err := config.NewConfig(flUseMetaService, flServerPort, flForceLocal, requireEnvVars) if err != nil { log.Fatal(err) } dogestryCli, err := cli.NewDogestryCli(cfg, flPullHosts) if err != nil { log.Fatal(err) } if flLockFile != "" { utils.LockByFile(dogestryCli, args, flLockFile) } else { err = dogestryCli.RunCmd(args...) dogestryCli.Cleanup() if err != nil { log.Fatal(err) } } } }
func main() { runtime.GOMAXPROCS(runtime.NumCPU()) flag.Usage = func() { fmt.Fprintln(os.Stderr, cli.HelpMessage) } flag.Parse() if flVersion { err := cli.PrintVersion() if err != nil { log.Fatal(err) } return } args := flag.Args() cfg, err := config.NewConfig(flUseMetaService) if err != nil { log.Fatal(err) } dogestryCli, err := cli.NewDogestryCli(cfg, flPullHosts) if err != nil { log.Fatal(err) } if flLockFile != "" { utils.LockByFile(dogestryCli, args, flLockFile) } else { err = dogestryCli.RunCmd(args...) if err == nil { dogestryCli.Cleanup() } else { dogestryCli.Cleanup() log.Fatal(err) } } }