func ConsoleRun(ui common.UI, cmd *cobra.Command, args []string) { if len(args) != 1 { common.ConsoleErr(cmd, fmt.Sprintf("Error: Expected 1 URL, got: %s", args)) return } g_config.Url = args[0] ui.ConfigSet(&g_config) common.ConsoleRun(workers.Run, "http", ui, cmd, args) }
func main() { if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } cmd := &cobra.Command{ Use: "hurl", Short: "hurl is a tool to hurl traffic at URLs", Long: `hurl is a flexiable benchmarking tool with the ability to scale out. Complete documentation is available online at: https://github.com/pquerna/hurl/`, Run: func(cmd *cobra.Command, args []string) { cmd.UsageFunc()(cmd) }, } cpuprofile := os.Getenv("CPUPROFILE") if cpuprofile != "" { f, err := os.Create(cpuprofile) if err != nil { fmt.Errorf("Error opening: %s, %v\n", cpuprofile, err) panic(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func() { for sig := range c { fmt.Printf("captured %v, stopping profiler and exiting..", sig) pprof.StopCPUProfile() os.Exit(1) } }() } subcmds := ui.ConsoleCommands() for _, c := range subcmds { cmd.AddCommand(c) } err := cmd.Execute() if err != nil { common.ConsoleErr(cmd, fmt.Sprintf("Error: %s", err)) } }
func ConsoleRun(ui common.UI, cmd *cobra.Command, args []string) { if len(args) != 1 { common.ConsoleErr(cmd, fmt.Sprintf("Error: Missing mode: %s", args)) return } // https://auth.api.rackspacecloud.com/v1.0 g_config.Mode = args[0] ui.ConfigSet(&g_config) common.ConsoleRun(workers.Run, "swift", ui, cmd, args) }