Esempio n. 1
0
func main() {
	flag.Parse()
	project_init.SetWorkingDir(*workingDir)
	initPackageFlags()
	validGaugeProject := true
	err := config.SetProjectRoot(flag.Args())
	if err != nil {
		validGaugeProject = false
	}
	env.LoadEnv(true)
	logger.Initialize(*verbosity, *logLevel, *simpleConsoleOutput)
	if *gaugeVersion {
		version.PrintVersion()
	} else if *daemonize {
		if validGaugeProject {
			api.RunInBackground(*apiPort)
		} else {
			logger.Log.Error(err.Error())
		}
	} else if *specFilesToFormat != "" {
		if validGaugeProject {
			formatter.FormatSpecFilesIn(*specFilesToFormat)
		} else {
			logger.Log.Error(err.Error())
		}
	} else if *initialize != "" {
		project_init.InitializeProject(*initialize)
	} else if *installZip != "" && *installPlugin != "" {
		install.InstallPluginZip(*installZip, *installPlugin)
	} else if *installPlugin != "" {
		install.DownloadAndInstallPlugin(*installPlugin, *installVersion)
	} else if *uninstallPlugin != "" {
		install.UninstallPlugin(*uninstallPlugin)
	} else if *installAll {
		install.InstallAllPlugins()
	} else if *update != "" {
		install.UpdatePlugin(*update)
	} else if *addPlugin != "" {
		install.AddPluginToProject(*addPlugin, *pluginArgs)
	} else if *refactorSteps != "" {
		if validGaugeProject {
			startChan := api.StartAPI()
			refactor.RefactorSteps(*refactorSteps, newStepName(), startChan)
		} else {
			logger.Log.Error(err.Error())
		}
	} else {
		if len(flag.Args()) == 0 {
			printUsage()
		} else if validGaugeProject {
			if *distribute != -1 {
				*doNotRandomize = true
			}
			execution.ExecuteSpecs(*parallel, flag.Args())
		} else {
			logger.Log.Error("Could not set project root: %s", err.Error())
			os.Exit(1)
		}
	}
}
Esempio n. 2
0
File: gauge.go Progetto: 0-T-0/gauge
func main() {
	flag.Parse()
	projectInit.SetWorkingDir(*workingDir)
	initPackageFlags()
	validGaugeProject := true
	err := config.SetProjectRoot(flag.Args())
	if err != nil {
		validGaugeProject = false
	}
	env.LoadEnv(*currentEnv)
	logger.Initialize(*logLevel)
	if *gaugeVersion {
		printVersion()
	} else if *initialize != "" {
		projectInit.InitializeProject(*initialize)
	} else if *installZip != "" && *installPlugin != "" {
		install.InstallPluginZip(*installZip, *installPlugin)
	} else if *installPlugin != "" {
		install.DownloadAndInstallPlugin(*installPlugin, *pluginVersion, "Successfully installed plugin => %s")
	} else if *uninstallPlugin != "" {
		install.UninstallPlugin(*uninstallPlugin, *pluginVersion)
	} else if *installAll {
		install.InstallAllPlugins()
	} else if *update != "" {
		install.DownloadAndInstallPlugin(*update, *pluginVersion, "Successfully updated plugin => %s")
	} else if *updateAll {
		install.UpdatePlugins()
	} else if *checkUpdates {
		install.PrintUpdateInfoWithDetails()
	} else if *addPlugin != "" {
		install.AddPluginToProject(*addPlugin, *pluginArgs)
	} else if *listTemplates {
		projectInit.ListTemplates()
	} else if flag.NFlag() == 0 && len(flag.Args()) == 0 {
		printUsage()
		os.Exit(0)
	} else if validGaugeProject {
		if *refactorSteps != "" {
			startChan := api.StartAPI()
			if len(flag.Args()) != 1 {
				logger.Error("flag needs two arguments: --refactor\n.Usage : gauge --refactor {old step} {new step}")
				os.Exit(1)
			}
			refactor.RefactorSteps(*refactorSteps, flag.Args()[0], startChan)
		} else if *daemonize {
			api.RunInBackground(*apiPort)
		} else if *specFilesToFormat != "" {
			formatter.FormatSpecFilesIn(*specFilesToFormat)
		} else if *validate {
			execution.Validate(flag.Args())
		} else {
			exitCode := execution.ExecuteSpecs(flag.Args())
			os.Exit(exitCode)
		}
	} else {
		logger.Error(err.Error())
		os.Exit(1)
	}
}
Esempio n. 3
0
func main() {
	flag.Parse()
	util.SetWorkingDir(*workingDir)
	initPackageFlags()
	validGaugeProject := true
	err := config.SetProjectRoot(flag.Args())
	if err != nil {
		validGaugeProject = false
	}
	env.LoadEnv(*currentEnv)
	logger.Initialize(*logLevel)
	if *gaugeVersion && *machineReadable {
		printJSONVersion()
	} else if *machineReadable {
		fmt.Printf("flag '--machine-readable' can only be used with '--version' or '-v'\n\n")
		fmt.Printf("Usage:\n\n")
		flag.PrintDefaults()
		os.Exit(1)
	} else if *gaugeVersion {
		printVersion()
	} else if *initialize != "" {
		projectInit.InitializeProject(*initialize)
	} else if *installZip != "" && *installPlugin != "" {
		install.HandleInstallResult(install.InstallPluginFromZipFile(*installZip, *installPlugin), *installPlugin, true)
	} else if *installPlugin != "" {
		install.HandleInstallResult(install.InstallPlugin(*installPlugin, *pluginVersion), *installPlugin, true)
	} else if *uninstallPlugin != "" {
		install.UninstallPlugin(*uninstallPlugin, *pluginVersion)
	} else if *installAll {
		install.InstallAllPlugins()
	} else if *update != "" {
		install.HandleUpdateResult(install.InstallPlugin(*update, *pluginVersion), *update, true)
	} else if *updateAll {
		install.UpdatePlugins()
	} else if *checkUpdates {
		install.PrintUpdateInfoWithDetails()
	} else if *addPlugin != "" {
		install.AddPluginToProject(*addPlugin, *pluginArgs)
	} else if *listTemplates {
		projectInit.ListTemplates()
	} else if flag.NFlag() == 0 && len(flag.Args()) == 0 {
		printUsage()
		os.Exit(0)
	} else if validGaugeProject {
		var specDirs = []string{common.SpecsDirectoryName}
		if len(flag.Args()) > 0 {
			specDirs = flag.Args()
		}
		if *refactorSteps != "" {
			refactorInit(flag.Args())
		} else if *daemonize {
			api.RunInBackground(*apiPort, specDirs)
		} else if *specFilesToFormat != "" {
			formatter.FormatSpecFilesIn(*specFilesToFormat)
		} else if *validate {
			validation.Validate(flag.Args())
		} else {
			exitCode := execution.ExecuteSpecs(specDirs)
			os.Exit(exitCode)
		}
	} else {
		logger.Fatalf(err.Error())
	}
}
Esempio n. 4
0
func main() {
	flag.Parse()
	projectInit.SetWorkingDir(*workingDir)
	initPackageFlags()
	validGaugeProject := true
	err := config.SetProjectRoot(flag.Args())
	if err != nil {
		validGaugeProject = false
	}
	env.LoadEnv(true)
	logger.Initialize(*verbosity, *logLevel)
	if *gaugeVersion {
		version.PrintVersion()
	} else if *daemonize {
		if validGaugeProject {
			api.RunInBackground(*apiPort)
		} else {
			logger.Error(err.Error())
		}
	} else if *specFilesToFormat != "" {
		if validGaugeProject {
			formatter.FormatSpecFilesIn(*specFilesToFormat)
		} else {
			logger.Error(err.Error())
		}
	} else if *initialize != "" {
		projectInit.InitializeProject(*initialize)
	} else if *installZip != "" && *installPlugin != "" {
		install.InstallPluginZip(*installZip, *installPlugin)
	} else if *installPlugin != "" {
		install.DownloadAndInstallPlugin(*installPlugin, *pluginVersion, "Successfully installed plugin => %s")
	} else if *uninstallPlugin != "" {
		install.UninstallPlugin(*uninstallPlugin, *pluginVersion)
	} else if *installAll {
		install.InstallAllPlugins()
	} else if *update != "" {
		install.DownloadAndInstallPlugin(*update, *pluginVersion, "Successfully updated plugin => %s")
	} else if *updateAll {
		install.UpdatePlugins()
	} else if *checkUpdates {
		install.PrintUpdateInfoWithDetails()
	} else if *addPlugin != "" {
		install.AddPluginToProject(*addPlugin, *pluginArgs)
	} else if *refactorSteps != "" {
		if validGaugeProject {
			startChan := api.StartAPI()
			refactor.RefactorSteps(*refactorSteps, newStepName(), startChan)
		} else {
			logger.Error(err.Error())
		}
	} else if *check {
		if validGaugeProject {
			execution.CheckSpecs(flag.Args())
		} else {
			logger.Error(err.Error())
		}
	} else {
		if len(flag.Args()) == 0 {
			printUsage()
		}
		if validGaugeProject {
			exitCode := execution.ExecuteSpecs(*parallel, flag.Args())
			os.Exit(exitCode)
		} else {
			logger.Error(err.Error())
		}
	}
}