Ejemplo n.º 1
0
func (c helpCommand) Execute(subcommands []string) cmdr.Result {
	help, err := c.CLI.Help(root, "sous", subcommands)
	if err != nil {
		return cmdr.EnsureErrorResult(err)
	}
	return cmdr.Successf(help)
}
Ejemplo n.º 2
0
// Execute fulfills the cmdr.Executor interface
func (sb *SousBuild) Execute(args []string) cmdr.Result {
	if len(args) != 0 {
		pwd, err := os.Getwd()
		if err != nil {
			return cmdr.EnsureErrorResult(err)
		}
		if err := sb.BuildManager.OffsetFromWorkdir(pwd, args[0]); err != nil {
			return cmdr.EnsureErrorResult(err)
		}
	}

	result, err := sb.BuildManager.Build()

	if err != nil {
		return cmdr.EnsureErrorResult(err)
	}
	return Success(result)
}
Ejemplo n.º 3
0
// Execute defines the behavior of `sous query gdm`
func (sh *SousHarvest) Execute(args []string) cmdr.Result {
	if len(args) == 0 {
		return cmdr.EnsureErrorResult(fmt.Errorf("need an argument to harvest"))
	}

	var err error
	for _, repoName := range args {
		err = sh.Registry.Warmup(sh.State.Defs.DockerRepo + "/" + repoName)
		if err != nil {
			break
		}
	}
	return ProduceResult(err)
}
Ejemplo n.º 4
0
// Plumbing injects a command with the current psyringe,
// then it Executes it, returning the result.
func (cli *CLI) Plumbing(cmd cmdr.Executor, args []string) cmdr.Result {
	if err := cli.SousGraph.Inject(cmd); err != nil {
		return cmdr.EnsureErrorResult(err)
	}
	return cmd.Execute(args)
}
Ejemplo n.º 5
0
// Func aliases, for convenience returning from commands.
var (
	SuccessData    = cmdr.SuccessData
	Successf       = cmdr.Successf
	Success        = cmdr.Success
	UsageErrorf    = cmdr.UsageErrorf
	OSErrorf       = cmdr.OSErrorf
	IOErrorf       = cmdr.IOErrorf
	InternalErrorf = cmdr.InternalErrorf
	GeneralErrorf  = func(format string, a ...interface{}) cmdr.ErrorResult {
		return EnsureErrorResult(fmt.Errorf(format, a...))
	}
	EnsureErrorResult = func(err error) cmdr.ErrorResult {
		sous.Log.Debug.Println(err)
		return cmdr.EnsureErrorResult(err)
	}
)

// ProduceResult converts errors into Results
func ProduceResult(err error) cmdr.Result {
	if err != nil {
		return EnsureErrorResult(err)
	}

	return Success()
}

type (
	// CLI describes the command line interface for Sous
	CLI struct {