func (c *UpCmd) Init(cc *cobra.Command) { cc.Use = "up [# path]" cc.Short = "upload BLOBs to bar server" cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure") cc.Flags().BoolVarP(&c.Squash, "squash", "", false, "squash uploaded BLOBs to manifests after upload") }
func (c *GitDivertFinishCmd) Init(cc *cobra.Command) { cc.Use = "finish" cc.Short = "finish covert op" cc.Flags().StringVarP(&c.Message, "message", "m", "", "git commit message") }
func (c *SpecExportCmd) Init(cc *cobra.Command) { cc.Use = "export [# path]" cc.Short = "export spec" cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure") cc.Flags().BoolVarP(&c.Upload, "upload", "u", false, "upload spec to bar server") cc.Flags().BoolVarP(&c.DoCC, "cc", "", false, "create carbon copy") }
func (c *GitInstallCmd) Init(cc *cobra.Command) { cc.Use = "install" cc.Short = "install bar support into git repo" cc.Flags().StringVarP(&c.Log, "log", "", logx.INFO, "installable logging level") cc.Flags() }
func (c *SpecImportCmd) Init(cc *cobra.Command) { cc.Use = "import [spec-id]" cc.Short = "import spec from bard server" cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure") cc.Flags().BoolVarP(&c.Raw, "raw", "", false, "read spec from STDIN instead request from bar server") cc.Flags().BoolVarP(&c.Squash, "squash", "", false, "write manifests after import") }
func (c *ServerRunCmd) Init(cc *cobra.Command) { cc.Use = "run" cc.Short = "run bar server instance (bard)" cc.Flags().StringVarP(&c.BindHTTP, "bind-http", "", ":3000", "http bind") cc.Flags().StringVarP(&c.BindRPC, "bind-rpc", "", ":3001", "rpc bind") cc.Flags().StringVarP(&c.HTTPEndpoint, "endpoint-http", "", "http://localhost:3000/v1", "http endpoint") cc.Flags().StringVarP(&c.BinDir, "bin-dir", "", "dist/bindir", "binaries directory") cc.Flags().StringVarP(&c.Storage, "storage", "", "block:root=data,split=2,max-files=128,pool=64", "storage configuration") }
func (c *LsCmd) Init(cc *cobra.Command) { cc.Use = "ls [# path]" cc.Short = "show info about bar-tracked BLOBs" cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure") cc.Flags().BoolVarP(&c.NoHeader, "no-header", "", false, "do not print header") cc.Flags().BoolVarP(&c.FullID, "full-id", "", false, "do not trim blob IDs") cc.Flags().BoolVarP(&c.NoBlobs, "no-blobs", "", false, "do not collect BLOBs") cc.Flags().BoolVarP(&c.NoManifests, "no-manifests", "", false, "do not collect manifests") cc.Flags().BoolVarP(&c.NoRemote, "no-remote", "", false, "do not request bard for BLOBs states") cc.Flags().BoolVarP(&c.NoName, "no-name", "", false, "do not print BLOB filenames") cc.Flags().BoolVarP(&c.NoID, "no-id", "", false, "do not print BLOB IDs") cc.Flags().BoolVarP(&c.NoSize, "no-size", "", false, "do not print BLOB sizes") }
func (c *PingCmd) Init(cc *cobra.Command) { cc.Use = "ping" cc.Short = "ping bar server" }
func (c *GitDivertStatusCmd) Init(cc *cobra.Command) { cc.Use = "status" cc.Short = "covert op status" }
func (c *GitDivertRootCmd) Init(cc *cobra.Command) { cc.Use = "divert" cc.Short = "git diversions" }
func (c *GitDivertAbortCmd) Init(cc *cobra.Command) { cc.Use = "abort" cc.Short = "abort covert op" }
func (c *VersionCmd) Init(cc *cobra.Command) { cc.Use = "version" cc.Short = "print version and exit" }
func cli() (*cobra.Command, error) { // parse the configDir argument cfgCmd := new(cobra.Command) cfgCmd.Flags().StringVarP(&configDir, "configDir", "d", "", "Configuration directory to be added on top of the search list") cfgCmd.ParseFlags(os.Args) // configuration parameters cfgParams, err := getConfigParams() if err != nil { return nil, err } // overwrites the configuration parameters with the ones specified in the command line (if any) appParams = &cfgParams rootCmd := new(cobra.Command) rootCmd.Flags().StringVarP(&configDir, "configDir", "d", "", "Configuration directory to be added on top of the search list") rootCmd.Flags().StringVarP(&appParams.log.Level, "logLevel", "o", cfgParams.log.Level, "Log level: EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG") rootCmd.Flags().BoolVarP(&appParams.serverMode, "serverMode", "s", cfgParams.serverMode, "Start an HTTP RESTful API server") rootCmd.Flags().StringVarP(&appParams.serverAddress, "serverAddress", "u", cfgParams.serverAddress, "HTTP API address (ip:port) or just (:port)") rootCmd.Flags().StringVarP(&appParams.charset, "charset", "c", cfgParams.charset, "Characters to use to generate a password") rootCmd.Flags().IntVarP(&appParams.length, "length", "l", cfgParams.length, "Length of each password (number of characters or bytes)") rootCmd.Flags().IntVarP(&appParams.quantity, "quantity", "q", cfgParams.quantity, "Number of passwords to generate") rootCmd.Flags().StringVarP(&appParams.stats.Prefix, "statsPrefix", "p", cfgParams.stats.Prefix, "StatsD bucket prefix name") rootCmd.Flags().StringVarP(&appParams.stats.Network, "statsNetwork", "k", cfgParams.stats.Network, "StatsD client network type (udp or tcp)") rootCmd.Flags().StringVarP(&appParams.stats.Address, "statsAddress", "m", cfgParams.stats.Address, "StatsD daemon address (ip:port) or just (:port)") rootCmd.Flags().IntVarP(&appParams.stats.FlushPeriod, "statsFlushPeriod", "r", cfgParams.stats.FlushPeriod, "StatsD client flush period in milliseconds") rootCmd.Use = "rndpwd" rootCmd.Short = "Command-line and Web-service Random Password Generator" rootCmd.Long = `rndpwd is a Command-line and Web-service Random Password Generator` rootCmd.RunE = func(cmd *cobra.Command, args []string) error { // check values err := checkParams(appParams) if err != nil { return err } // initialize StatsD client (ignore errors) initStats(appParams.stats) defer stats.Close() if appParams.serverMode { // start the HTTP server return startServer(appParams.serverAddress) } // generate and print the passwords for _, psw := range getAllPassword(appParams) { fmt.Println(psw) } return nil } // sub-command to print the version var versionCmd = &cobra.Command{ Use: "version", Short: "print this program version", Long: `print this program version`, Run: func(cmd *cobra.Command, args []string) { fmt.Println(ProgramVersion) }, } rootCmd.AddCommand(versionCmd) return rootCmd, nil }
func (c *GitPreCommitCmd) Init(cc *cobra.Command) { cc.Use = "pre-commit" cc.Short = "git pre-commit hook" }
func (c *DownCmd) Init(cc *cobra.Command) { cc.Use = "down [# path]" cc.Short = "download BLOBs from bar server" cc.Flags().BoolVarP(&c.UseGit, "git", "", false, "use git infrastructure") }
func (c *GitSmudgeCmd) Init(cc *cobra.Command) { cc.Use = "smudge" cc.Short = "git smudge filter" }
func (c *GitCleanCmd) Init(cc *cobra.Command) { cc.Use = "clean" cc.Short = "git clean filter" cc.Flags().BoolVarP(&c.Id, "id", "", false, "print generated id instead manifest") }
func (c *GitDivertPushCmd) Init(cc *cobra.Command) { cc.Use = "push [upstream] branch" cc.Short = "push specific branch" }
func (c *GitCmd) Init(cc *cobra.Command) { cc.Use = "git" cc.Short = "git-specific operations" }
func (c *ServerCmd) Init(cc *cobra.Command) { cc.Use = "server" cc.Short = "bar server" }
func (c *GitDivertBeginCmd) Init(cc *cobra.Command) { cc.Use = "begin branch [# tree-ish ...]" cc.Short = "begin covert op" }
func (c *SpecRootCmd) Init(cc *cobra.Command) { cc.Use = "spec" cc.Short = "spec operations" }