func main() { fs := goptions.NewFlagSet("picli", &options) err := fs.Parse(os.Args[1:]) if err == goptions.ErrHelpRequest { fs.PrintHelp(os.Stderr) return } options.Server = validateServer(options.Server) key := prepareKey() switch options.Verbs { case "upload": format() upload(key) case "logs": logs(key) case "format": format() default: if err != nil { fmt.Printf("Error: %s\n", err) } fs.PrintHelp(os.Stderr) return } }
func init() { flagSet := goptions.NewFlagSet(filepath.Base(os.Args[0]), &options) flagSet.HelpFunc = helpFunc err := flagSet.Parse(os.Args[1:]) if err != nil || len(options.Remainder) <= 0 || len(options.Verbs) <= 0 { if err != goptions.ErrHelpRequest && err != nil { log.Printf("Error: %s", err) } flagSet.PrintHelp(os.Stderr) os.Exit(1) } if options.CacheControl != "" { log.Printf("Monkey patching default transport...") monkeyPatchDefaultTransport() } }