func main() { bin := comandante.New("comandante_example", "Example program showing how to use Comandante") bin.IncludeHelp() // autogenerate a "help" command // list command listCmd := comandante.NewCommand("list", "list files in a directory", cmds.ListAction) listCmd.Documentation = cmds.ListDoc bin.RegisterCommand(listCmd) // http get command getCmd := comandante.NewCommand("get", "GETs the contents of a webpage", cmds.GetAction) getCmd.FlagInit = cmds.GetFlagHandler // use the flag package to get a url getCmd.Documentation = cmds.GetDoc bin.RegisterCommand(getCmd) // run the commands if err := bin.Run(); err != nil { fmt.Fprintln(os.Stderr, err) } }
func main() { bin := comandante.New("ff6", "Manage Final Fantasy VI mobile save files") bin.IncludeHelp() tj := comandante.NewCommand("tojson", "Convert .sav save file to .json", tojson) tj.FlagInit = func(fs *flag.FlagSet) { fs.StringVar(&savfile, "i", savfile, "Input .sav file") fs.StringVar(&jsonfile, "o", jsonfile, "Output .json file") } bin.RegisterCommand(tj) fj := comandante.NewCommand("fromjson", "Convert .json save file to .sav", fromjson) fj.FlagInit = func(fs *flag.FlagSet) { fs.StringVar(&jsonfile, "i", jsonfile, "Input .json file") fs.StringVar(&savfile, "o", savfile, "Output .sav file") } bin.RegisterCommand(fj) flag.Parse() if err := bin.Run(); err != nil { log.Fatalln(err) } }
func main() { // get the environment for the config appEnv := "" env := os.Getenv("BTBBOARD_ENV") switch env { case "dev", "test", "prod": appEnv = env default: appEnv = "dev" } config.LoadConfig(appEnv) // make the package level database connection if err := models.ConnectToDB(config.String("database.host"), config.String("database.db")); err != nil { fmt.Fprintln(os.Stderr, "Could not connect to the database") os.Exit(1) } defer models.CloseDB() bin := comandante.New("btbboard", "BitBar dashboard") bin.IncludeHelp() // add indexes to the database addIndexes := comandante.NewCommand("index", "Add indexes to the database", cmds.IndexAction) addIndexes.Documentation = cmds.IndexDoc bin.RegisterCommand(addIndexes) // update vertcoin prices updateCoinPrices := comandante.NewCommand("update_coin_prices", "Get updated vertcoin prices", cmds.UpdateAction(&updaters.CoinPrice{})) updateCoinPrices.Documentation = cmds.UpdateCoinPricesDoc bin.RegisterCommand(updateCoinPrices) // pricing rollup for the graph rollupPricing := comandante.NewCommand("pricing_rollup", "Aggregate pricing information", cmds.PricingRollupAction) rollupPricing.Documentation = cmds.PricingRollupDoc bin.RegisterCommand(rollupPricing) // update network info updateNetwork := comandante.NewCommand("update_network", "Get updated network information", cmds.UpdateAction(&updaters.Network{})) updateNetwork.Documentation = cmds.UpdateCoinPricesDoc bin.RegisterCommand(updateNetwork) // update reddit stories updateReddit := comandante.NewCommand("update_reddit", "Get new /r/vertcoin posts", cmds.UpdateAction(&updaters.Reddit{})) updateReddit.Documentation = cmds.UpdateRedditDoc bin.RegisterCommand(updateReddit) // run web service webService := comandante.NewCommand("serve", "Start the VTCBoard web server", cmds.ServeAction) webService.Documentation = cmds.ServerDoc bin.RegisterCommand(webService) if err := bin.Run(); err != nil { fmt.Fprintln(os.Stderr, err) } }
func main() { config.LoadConfigFile("config.toml") bin := comandante.New("folkpocket", "Read folklore.org in pocket") bin.IncludeHelp() // scrape command scrapeCmd := comandante.NewCommand("scrape", "Scrape folklore.org story URLs and save them in the database.", cmds.ScrapeAction) scrapeCmd.Documentation = cmds.ScrapeDoc bin.RegisterCommand(scrapeCmd) // serve command if err := bin.Run(); err != nil { fmt.Fprintln(os.Stderr, err) } }
func main() { bin := comandante.New("auth", "Authenticator app") bin.IncludeHelp() initCmd := comandante.NewCommand("init", "Initialize storage", cmds.InitAction) initCmd.FlagInit = cmds.InitFlagHandler initCmd.Documentation = cmds.InitDoc bin.RegisterCommand(initCmd) listCmd := comandante.NewCommand("list", "List stored services", cmds.ListAction) listCmd.FlagInit = cmds.ListFlagHandler // use the flag package to get a url listCmd.Documentation = cmds.ListDoc bin.RegisterCommand(listCmd) addCmd := comandante.NewCommand("add", "Add a new service", cmds.AddAction) addCmd.FlagInit = cmds.AddFlagHandler // use the flag package to add a url addCmd.Documentation = cmds.AddDoc bin.RegisterCommand(addCmd) getCmd := comandante.NewCommand("gen", "Generate a TOTP code for a given service", cmds.GetAction) getCmd.FlagInit = cmds.GetFlagHandler // use the flag package to get a url getCmd.Documentation = cmds.GetDoc bin.RegisterCommand(getCmd) qrCmd := comandante.NewCommand("qr", "qr PNG QR Code", cmds.QrAction) qrCmd.FlagInit = cmds.QrFlagHandler // use the flag package to qr a url qrCmd.Documentation = cmds.QrDoc bin.RegisterCommand(qrCmd) exportCmd := comandante.NewCommand("export", "export database to json", cmds.ExportAction) exportCmd.FlagInit = cmds.ExportFlagHandler exportCmd.Documentation = cmds.ExportDoc bin.RegisterCommand(exportCmd) // run the command if err := bin.Run(); err != nil { fmt.Fprintln(os.Stderr, err) } }
func init() { install := comandante.NewCommand("install", "Install editor hooks", installHooks) install.FlagInit = installFlagInit bin.RegisterCommand(install) }
func init() { completeAt := comandante.NewCommand("completeat", "Run a completeat operation", runCompleteAt) completeAt.FlagInit = completeAtFlagInit bin.RegisterCommand(completeAt) }
func init() { daemon := comandante.NewCommand("daemon", "Run rpc daemon", runRpcDaemon) daemon.FlagInit = daemonFlagInit bin.RegisterCommand(daemon) }
func init() { license := comandante.NewCommand("license", "Print licenses used", printLicenses) bin.RegisterCommand(license) }