Esempio n. 1
0
// Run Parity
func (c *AttachCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.StringVar(&c.Service, "service", "web", "Service to shell into. Defaults to 'web'")
	cmdFlags.StringVar(&c.ParityFile, "config", utils.DefaultParityConfigurationFile(), "Parity configuration file")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	c.Meta.Ui.Output("Attaching to running container")
	parity := app.New(&config.Config{ConfigFile: c.ParityFile})
	parity.LoadPlugins()

	if shell, err := parity.GetShellPlugin("compose"); err == nil {
		err := shell.Attach(app.ShellConfig{
			Service: c.Service,
		})
		if err != nil {
			Ui.Error(fmt.Sprintf("Unable to attach to container: %s", err.Error()))
		}
	} else {
		Ui.Error(fmt.Sprintf("Unable to attach to container: %s", err.Error()))
	}

	return 0
}
Esempio n. 2
0
// Run Parity
func (c *RunCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.BoolVar(&c.Verbose, "verbose", true, "Enable verbose output")
	cmdFlags.BoolVar(&c.X, "x", false, "Enable X redirection (Mac OSX Only)")
	cmdFlags.StringVar(&c.ConfigFile, "config", utils.DefaultParityConfigurationFile(), "Enable verbose output")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	if !c.Verbose {
		log.SetOutput(ioutil.Discard)
	}

	parity := app.New(&config.Config{Ui: c.Meta.Ui, ConfigFile: c.ConfigFile})
	parity.Run()

	return 0
}
Esempio n. 3
0
// Run Parity
func (c *BuildCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.BoolVar(&c.Verbose, "verbose", true, "Enable verbose output")
	cmdFlags.StringVar(&c.ConfigFile, "config", utils.DefaultParityConfigurationFile(), "Specifies the Parity configuration file path")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	if !c.Verbose {
		log.SetOutput(ioutil.Discard)
	}

	c.Meta.Ui.Output("Building containers")
	parity := app.New(&config.Config{Ui: c.Meta.Ui, ConfigFile: c.ConfigFile})
	if err := parity.Build(); err != nil {
		c.Meta.Ui.Error(err.Error())
	}

	return 0
}