cmd

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildCmd = &cobra.Command{
	Use:   "build VARIANTFILE",
	Short: "Create a single executable from the Variantfile",
	Long:  `Create a single executable from the Variantfile`,
	RunE: func(cmd *cobra.Command, args []string) error {
		taskDef, err := load.File(args[0])
		if err != nil {
			return err
		}
		fmt.Fprintf(os.Stdout, "%#v", taskDef)
		return nil
	},
}
View Source
var EnvCmd = &cobra.Command{
	Use:   "env",
	Short: "Print currently selected environment",
	Long: `Print currently selected environment. The environment can be via the command "var env set" or "var env switch".

Example:
var env switch dev
var env #=> Prints "dev"
`,
	Run: func(cmd *cobra.Command, args []string) {
		env, err := env.Get()
		if err != nil {
			panic(err)
		}
		fmt.Println(env)
	},
}
View Source
var InitCmd = &cobra.Command{
	Use:   "init NAME",
	Short: "Create a Variant command",
	Long: `Create a Variant command with the specified NAME

Example:
cat <<EOF | variant init mycmd
tasks:
  script: |
    echo Hello Variant!
EOF

./mycmd
`,
	Run: func(cmd *cobra.Command, args []string) {
		bytes, err := ioutil.ReadAll(os.Stdin)
		if err != nil {
			panic(err)
		}
		header := "#!/usr/bin/env variant\n\n"
		bytes = append([]byte(header), bytes...)
		if err := ioutil.WriteFile(args[0], bytes, 0755); err != nil {
			panic(err)
		}
	},
}

Functions

func Def added in v0.29.0

func Def(rootTaskConfig *variant.TaskDef, opts variant.Opts)

func Dev added in v0.29.0

func Dev()

func Run added in v0.29.0

func Run(commandPath string, args []string, taskDef *variant.TaskDef, opts variant.Opts) (map[string]string, error)

func VersionCmd

func VersionCmd(log *logrus.Logger) *cobra.Command

func YAML added in v0.29.0

func YAML(yaml string)

Types

type Command added in v0.29.0

type Command struct {
	// contains filtered or unexported fields
}

func New added in v0.29.0

func New(commanPath string, taskDef *variant.TaskDef, opts variant.Opts) *Command

func (*Command) Run added in v0.29.0

func (c *Command) Run(args []string) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL