Esempio n. 1
33
func main() {
	log.SetOutput(ioutil.Discard)

	args := os.Args[1:]
	for _, arg := range args {
		if arg == "-v" || arg == "--version" {
			newArgs := make([]string, len(args)+1)
			newArgs[0] = "version"
			copy(newArgs[1:], args)
			args = newArgs
			break
		}
	}

	cli := cli.CLI{
		Args:     args,
		Commands: Commands,
		HelpFunc: cli.BasicHelpFunc("dynamodb-cli"),
	}

	status, err := cli.Run()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
		os.Exit(1)
	}

	os.Exit(status)
}
Esempio n. 2
-2
// it all starts here
func main() {
	var c *cli.CLI // cli object
	var status int // exit status
	var err error  // general error holder

	// init and populate cli object
	c = cli.NewCLI(appName, appVersion)
	c.Args = os.Args[1:]     // arguments minus command
	c.Commands = cliCommands // see commands.go

	// run command and check return
	if status, err = c.Run(); err != nil {
		fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err)
	}

	// exit
	os.Exit(status)
}