cmd

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 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)
		}
	},
}
View Source
var UtilsCmd = &cobra.Command{
	Use:   "utils 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 GetStatus added in v0.36.1

func GetStatus(err error, opts variant.Opts) int

func HandleError added in v0.36.0

func HandleError(err error, opts variant.Opts) (string, int)

func HandleErrorAndExit added in v0.36.4

func HandleErrorAndExit(err error, opts variant.Opts)

func LogAndExit added in v0.36.4

func LogAndExit(opts variant.Opts, msg string, status int)

func MustRun added in v0.36.0

func MustRun()

func Run added in v0.29.0

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

func RunE added in v0.36.0

func RunE() (variant.Opts, 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