Пример #1
0
func Run(c *cli.Context) {
	container := &containers.Container{}

	containerPwd, err := containers.PrepareContainer(container)
	utils.CheckError(err)

	cmd := exec.Command("bash", "-c", fmt.Sprintf("cd %s; pwd; docker %s", containerPwd, strings.Join(c.Args(), " ")))

	stdout, err := cmd.StdoutPipe()
	utils.CheckError(err)

	stderr, err := cmd.StderrPipe()
	utils.CheckError(err)

	err = cmd.Start()
	if err != nil {
		log.Errorf("%s", err.Error())
	}

	go io.Copy(os.Stdout, stdout)
	go io.Copy(os.Stderr, stderr)

	err = cmd.Wait()
}
Пример #2
0
Файл: tt.go Проект: flexiant/tt
func main() {
	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Author = "Concerto Contributors"
	app.Email = "https://github.com/flexiant/tt"

	app.CommandNotFound = cmdNotFound
	app.Usage = "Wrapper to allow templating for Docker and Compose"
	app.Version = VERSION

	currentDir, err := os.Getwd()
	utils.CheckError(err)
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "debug, D",
			Usage: "Enable debug mode",
		},
		cli.StringFlag{
			EnvVar: "TT_ORIGIN",
			Name:   "origin, o",
			Usage:  "Default Folder",
			Value:  currentDir,
		},
		cli.StringFlag{
			EnvVar: "TT_CONFIG",
			Name:   "config, c",
			Usage:  "Config Variables",
		},
	}

	app.Before = prepareFlags

	app.Commands = []cli.Command{
		{
			Name:   "docker",
			Usage:  "Manages docker with templating",
			Action: docker.Run,
		},
	}

	app.Run(os.Args)
}