Exemplo n.º 1
0
func pluginInstall(c *cli.Context) {
	// Input validation
	pluginSource := c.String("source")
	if pluginSource == "" {
		log.Fatalln("Missing required input: source")
	}

	pluginName := c.String("name")
	if pluginName == "" {
		log.Fatalf("Missing required input: name")
	}

	pluginType := c.String("type")
	if pluginType == "" {
		pluginType = plugins.TypeGeneric
	}

	// Install
	log.Infof("=> Installing plugin (%s)...", plugins.PrintableName(pluginName, pluginType))
	printableName, err := plugins.InstallPlugin(c.App.Version, pluginSource, pluginName, pluginType)
	if err != nil {
		log.Fatalf("Failed to install plugin, err: %s", err)
	}
	fmt.Println()
	log.Infoln(colorstring.Greenf("Plugin (%s) installed", printableName))
}
Exemplo n.º 2
0
// Run ...
func Run() {
	// Parse cl
	cli.VersionPrinter = printVersion

	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Usage = "Bitrise Automations Workflow Runner"
	app.Version = "1.3.0"

	app.Author = ""
	app.Email = ""

	app.Before = before

	app.Flags = flags
	app.Commands = commands

	app.Action = func(c *cli.Context) {
		pluginName, pluginType, pluginArgs, isPlugin := plugins.ParseArgs(c.Args())
		if isPlugin {
			log.SetLevel(log.DebugLevel)
			log.Debugln()
			log.Debugf("Try to run bitrise plugin: (%s) (type: %s) with args: (%v)", pluginName, pluginType, pluginArgs)

			printableName := plugins.PrintableName(pluginName, pluginType)
			log.Debugf("Plugin: %v", printableName)

			plugin, err := plugins.GetPlugin(pluginName, pluginType)
			if err != nil {
				log.Fatalf("Failed to get plugin (%s), err: %s", printableName, err)
			}

			messageFromPlugin, err := plugins.RunPlugin(app.Version, plugin, pluginArgs)
			log.Debugf("message from plugin: %s", messageFromPlugin)

			if err != nil {
				log.Fatalf("Failed to run plugin (%s), err: %s", printableName, err)
			}
		} else {
			cli.ShowAppHelp(c)
		}
	}

	if err := app.Run(os.Args); err != nil {
		log.Fatal("Finished with Error:", err)
	}
}