defaultcmd

package
v2.0.0-snapshot...-58e3a78 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "default",
	ShortHelp: "[DEPRECATED] Set the default associated environment",
	LongHelp: "The `default` command has been deprecated! It will be removed in a future version. Please specify `-E` on all commands instead of using the default.\n\n" +
		"`default` sets the default environment for all commands that don't specify an environment with the `-E` flag. " +
		"See [scope](#global-scope) for more information on scope and default environments. " +
		"When setting a default environment, you must give the alias of the environment if one was set when it was associated and not the real environment name. Here is a sample command\n\n" +
		"```\ncatalyze default prod\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			alias := cmd.StringArg("ENV_ALIAS", "", "The alias of an already associated environment to set as the default")
			cmd.Action = func() {
				if err := config.CheckRequiredAssociation(true, false, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdDefault(*alias, New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			cmd.Spec = "ENV_ALIAS"
		}
	},
}

Cmd is the contract between the user and the CLI. This specifies the command name, arguments, and required/optional arguments and flags for the command.

Functions

func CmdDefault

func CmdDefault(alias string, id IDefault) error

Types

type IDefault

type IDefault interface {
	Set(alias string) error
}

IDefault

func New

func New(settings *models.Settings) IDefault

New returns an instance of IDefault

type SDefault

type SDefault struct {
	Settings *models.Settings
}

SDefault is a concrete implementation of IDefault

func (*SDefault) Set

func (d *SDefault) Set(alias string) error

Set sets the default environment. This environment must already be associated. Any commands run outside of a git directory will use the default environment for context.

Jump to

Keyboard shortcuts

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