func main() { flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } if *flagDebug { logger.Enable(lib.MyName() + ".log") } if *flagVersion { fmt.Println(lib.MyName() + " version " + version.Version()) return } if *flagHelp { usage() return } conn := connector.NewConnector(flagHost, flagSocket, flagPort, flagUser, flagPassword, flagDefaultsFile) disp := display.NewScreenDisplay(*flagLimit, false) app := app.NewApp(conn, *flagInterval, *flagCount, false, *flagView, disp) app.Run() app.Cleanup() }
func main() { connectorFlags = connector.Flags{ DefaultsFile: flag.String("defaults-file", "", "Define the defaults file to read"), Host: flag.String("host", "", "Provide the hostname of the MySQL to connect to"), Password: flag.String("password", "", "Provide the password when connecting to the MySQL server"), Port: flag.Int("port", 0, "Provide the port number of the MySQL to connect to (default: 3306)"), /* Port is deliberately 0 here, defaults to 3306 elsewhere */ Socket: flag.String("socket", "", "Provide the path to the local MySQL server to connect to"), User: flag.String("user", "", "Provide the username to connect with to MySQL (default: $USER)"), UseEnvironment: flag.Bool("use-environment", false, "Use the environment variable MYSQL_DSN (go dsn) to connect with to MySQL"), } flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } if *flagDebug { logger.Enable() } if *flagVersion { fmt.Println(lib.MyName() + " version " + version.Version()) return } if *flagHelp { usage() return } settings := app.Settings{ Anonymise: *flagAnonymise, Conn: connector.NewConnector(connectorFlags), Interval: *flagInterval, Count: *flagCount, Stdout: false, View: *flagView, Disp: display.NewScreenDisplay(*flagLimit, false), } app := app.NewApp(settings) app.Run() app.Cleanup() }