Example #1
0
// Command switch for commands requiring a config to be loaded
func ConfigCommandSwitch(args string, err error) (exitCode int) {
	config = maestro.BuildMaestroConfig(*flagConfigFile)
	switch kingpin.MustParse(args, err) {
	case flagConfig.FullCommand():
		config.Print()
	case flagUser.FullCommand():
		config.GetUsername()
	case flagBuildUnits.FullCommand():
		maestro.MaestroBuildLocalUnits()
	case flagBuildImages.FullCommand():
		exitCode = maestro.MaestroBuildContainers(*flagBuildImagesUnit)
	case flagBuildStatus.FullCommand():
		exitCode = maestro.MaestroBuildStatus(*flagBuildStatusUnit)
	case flagBuildNuke.FullCommand():
		exitCode = maestro.MaestroBuildNuke(*flagBuildNukeUnit)
	case flagStatus.FullCommand():
		exitCode = maestro.MaestroStatus("")
	case flagJournal.FullCommand():
		exitCode = maestro.MaestroJournal("", *flagJournalFollow, *flagJournalAll)
	case flagRun.FullCommand():
		exitCode = maestro.MaestroRun(*flagRunUnit)
	case flagStop.FullCommand():
		exitCode = maestro.MaestroStop("")
	case flagNuke.FullCommand():
		exitCode = maestro.MaestroNuke("")
	}
	return
}
Example #2
0
// Initial switch for commands not requiring a configuration
func NoConfigCommandSwitch(args string, err error) (exitCode int) {
	exitCode = -1
	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	case flagCoreStatus.FullCommand():
		exitCode = maestro.MaestroCoreStatus()
	case flagExec.FullCommand():
		output := make(chan string)
		exit := make(chan int)
		go maestro.FleetExec(*flagExecArgs, output, exit)
		exitCode = maestro.FleetProcessOutput(output, exit)
	case flagEtcd.FullCommand():
		exitCode = maestro.EtcdPullKeys(*flagEtcdSkydns, *flagEtcdAll, *flagEtcdKey)
	case flagNuke.FullCommand():
		if *flagNukeAll {
			exitCode = maestro.MaestroNukeAll()
		} else if *flagNukeUnit != "" {
			exitCode = maestro.MaestroNuke(*flagNukeUnit)
		}
	case flagStatus.FullCommand():
		if *flagStatusUnit != "" {
			exitCode = maestro.MaestroStatus(*flagStatusUnit)
		}
	case flagJournal.FullCommand():
		if *flagJournalUnit != "" {
			exitCode = maestro.MaestroJournal(*flagJournalUnit, *flagJournalFollow, *flagJournalAll)
		}
	case flagStop.FullCommand():
		if *flagStopUnit != "" {
			exitCode = maestro.MaestroStop(*flagStopUnit)
		}
	}
	return
}