package main import ( "flag" "fmt" "gosvc" "os" "robotfs/config" "robotfs/utils" ) const usage = `Usage: robotfs [options] Options: --config string Path to config file (required) --version Show version information --help Show this help message Example: robotfs --config=/path/to/config.yaml` var ( configFile = flag.String("config", "", "path to config file") version = flag.Bool("version", false, "show version information") help = flag.Bool("help", false, "show help message") ) func printUsage() { fmt.Println(usage) } func main() { flag.Parse() if *help { printUsage() return } if *version { gosvc.Config.PrintVersion() return } if *configFile != "" { err := utils.LoadConfiguration(*configFile) if err != nil { fmt.Println("load config file failed, " + err.Error()) os.Exit(1) } } else { fmt.Println("Error: --config flag is required") printUsage() os.Exit(1) } config.SetupServiceConfig() svc, err := CreateService() if err != nil { fmt.Println("create service failed, " + err.Error()) return } err = gosvc.Run(svc) if err != nil { fmt.Println("run service failed, " + err.Error()) return } }