Ejemplo n.º 1
0
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")
}
Ejemplo n.º 2
0
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")
}
Ejemplo n.º 3
0
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")
}
Ejemplo n.º 4
0
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()
}
Ejemplo n.º 5
0
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")
}
Ejemplo n.º 6
0
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")
}
Ejemplo n.º 7
0
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")
}
Ejemplo n.º 8
0
func (c *PingCmd) Init(cc *cobra.Command) {
	cc.Use = "ping"
	cc.Short = "ping bar server"
}
Ejemplo n.º 9
0
func (c *GitDivertStatusCmd) Init(cc *cobra.Command) {
	cc.Use = "status"
	cc.Short = "covert op status"
}
Ejemplo n.º 10
0
func (c *GitDivertRootCmd) Init(cc *cobra.Command) {
	cc.Use = "divert"
	cc.Short = "git diversions"
}
Ejemplo n.º 11
0
func (c *GitDivertAbortCmd) Init(cc *cobra.Command) {
	cc.Use = "abort"
	cc.Short = "abort covert op"
}
Ejemplo n.º 12
0
func (c *VersionCmd) Init(cc *cobra.Command) {
	cc.Use = "version"
	cc.Short = "print version and exit"
}
Ejemplo n.º 13
0
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
}
Ejemplo n.º 14
0
func (c *GitPreCommitCmd) Init(cc *cobra.Command) {
	cc.Use = "pre-commit"
	cc.Short = "git pre-commit hook"
}
Ejemplo n.º 15
0
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")
}
Ejemplo n.º 16
0
func (c *GitSmudgeCmd) Init(cc *cobra.Command) {
	cc.Use = "smudge"
	cc.Short = "git smudge filter"
}
Ejemplo n.º 17
0
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")
}
Ejemplo n.º 18
0
func (c *GitDivertPushCmd) Init(cc *cobra.Command) {
	cc.Use = "push [upstream] branch"
	cc.Short = "push specific branch"
}
Ejemplo n.º 19
0
func (c *GitCmd) Init(cc *cobra.Command) {
	cc.Use = "git"
	cc.Short = "git-specific operations"
}
Ejemplo n.º 20
0
func (c *ServerCmd) Init(cc *cobra.Command) {
	cc.Use = "server"
	cc.Short = "bar server"
}
Ejemplo n.º 21
0
func (c *GitDivertBeginCmd) Init(cc *cobra.Command) {
	cc.Use = "begin branch [# tree-ish ...]"
	cc.Short = "begin covert op"
}
Ejemplo n.º 22
0
func (c *SpecRootCmd) Init(cc *cobra.Command) {
	cc.Use = "spec"
	cc.Short = "spec operations"
}