Example #1
0
//InitGeneralFlags provides general configuration.
//Any subcommand can be run after it
func InitGeneralFlags() {
	flag.Bool("version", false, "Displays the software version")
	logLevel := flag.Int("log-level", 1, "Set how much information to display when running commands. 0 = most, 6=least")
	flag.String("answers", "", "Set the path to the answers file")
	flag.Bool("dry-run", false, "Don't actually call provider. The commands that"+
		"should be run will be sent to stdout but not run.")
	flag.Parse()

	//Verify that arguments have been provided
	if len(flag.Args()) < 1 {
		flag.Usage()
		os.Exit(0)
	}

	logging.SetLogLevel(*logLevel)
}
Example #2
0
//InitApp initializes the application
func InitApp(commands []cli.Command) *cli.App {
	var logLevel int
	app := cli.NewApp()
	app.Name = "atomicgo"
	app.Usage = "A nulecule implementation written in Go"
	app.Version = constants.ATOMICAPPVERSION
	app.Commands = commands
	app.Flags = globalFlagSet()

	//Handle global options such as logging level
	app.Before = func(c *cli.Context) error {
		logLevel = c.GlobalInt("log-level")
		logging.SetLogLevel(logLevel)
		return nil
	}

	app.Run(os.Args)
	return app
}