commands

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2015 License: GPL-2.0 Imports: 16 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Text = iota
	Json
)

type of output format for commands

View Source
const (
	Mercurial = iota
	Source
	Binary
)

possible installation sources

Variables

View Source
var Commands map[string]*Command = map[string]*Command{}

commands map, useful for the help command

View Source
var ErrNotInstalled = errors.New("Go version not installed")

error used when Go version used for mkenv is not installed yet

Functions

func Help added in v1.1.1

func Help(args ...string)

help function

func IsNotInstalledError

func IsNotInstalledError(err error) bool

determine if the given error is of ErrNotInstalled type

func NonCommand added in v1.1.1

func NonCommand(cmd string)

used when the commans is not found

func Usage added in v1.1.1

func Usage()

calls usage to prints usage information and exits

func Version added in v1.1.1

func Version(version string)

version function

Types

type BriefJSON

type BriefJSON struct {
	Installed []string `json:"installed,omitempty"`
	Available []string `json:"available,omitempty"`
}

json brief output structure

type Command added in v1.1.1

type Command struct {
	Name    string       // command name
	Usage   string       // short line that contains the usage help
	Short   string       // short description
	Long    string       // long description
	Execute commandFunc  // run the command
	Flag    flag.FlagSet // set of flags for this command
}

command structure

func (*Command) DisplayUsageAndExit added in v1.1.1

func (cmd *Command) DisplayUsageAndExit()

display the usage and exit

func (*Command) String added in v1.1.1

func (cmd *Command) String() string

return a string representation of the command

type EnvironmentsJSON

type EnvironmentsJSON struct {
	Available []string `json:"available"`
	Invalid   []string `json:"invalid,omitempty"`
}

type EnvironmentsList

type EnvironmentsList struct {
	DisplayAs int
}

EnvironmentsList command

func NewEnvironmentsList

func NewEnvironmentsList(options ...func(*EnvironmentsList)) *EnvironmentsList

Create a new lsenv adn returns back it's address

func (*EnvironmentsList) Run

func (e *EnvironmentsList) Run() (string, error)

implements the Runner interface returning back a list of available environments in text or json format depending on the given options

type Export

type Export struct {
	Environment string
	Name        string
	Force       bool
	Prettify    bool
	// contains filtered or unexported fields
}

export command

func NewExport

func NewExport(options ...func(e *Export)) *Export

create a new export command and return back it's address

func (*Export) Err

func (e *Export) Err() error

expose the internal err property

func (*Export) Exists

func (e *Export) Exists() bool

check if a manifest already exists for the given environment

func (*Export) LoadEnvironment

func (e *Export) LoadEnvironment() (*env.Environment, error)

load environment using the activate environment script, return an error if the operation can't be completed

func (*Export) Run

func (e *Export) Run() (string, error)

implements the Runner interface executing the environment export

type Import

type Import struct {
	Manifest string
	Prompt   string
	Verbose  bool
	Force    bool
}

func NewImport

func NewImport(options ...func(i *Import)) *Import

create a new import command and return back it's address

func (*Import) Run

func (i *Import) Run() (string, error)

implements the Runner interface importing and recreating an exported env

type Install

type Install struct {
	Force     bool
	Source    int
	Version   string
	DisplayAs int
	Verbose   bool
	NoCGO     bool
	BootStrap string
}

install command

func NewInstall

func NewInstall(options ...func(i *Install)) *Install

Create a new install command and return back it's address

func (*Install) Run

func (i *Install) Run() (string, error)

implements the Runner interface executing the required installation

type List

type List struct {
	ShowInstalled    bool
	ShowNotInstalled bool
	ShowBoth         bool
	DisplayAs        int
}

list command

func NewList

func NewList(options ...func(*List)) *List

Create a new list and return back it's address

func (*List) Run

func (l *List) Run() (string, error)

implements the Runner interface returning back a list of installed go versions, a list of not installed versions or all versions depending on the list options

type Mkenv

type Mkenv struct {
	Force   bool
	Name    string
	Prompt  string
	Version string
}

mkenv command

func NewMkenv

func NewMkenv(options ...func(i *Mkenv)) *Mkenv

Create a new mkenv command and return back it's address

func (*Mkenv) Run

func (m *Mkenv) Run() (string, error)

implements the Runner interface creating the new virtual environment

type Runner

type Runner interface {
	Run() (string, error)
}

Runner is a interface that wraps the execution of a command

Runner returns a string (that can be empty) with the results of the executed command and an error, that should be nil if no error occurred

Jump to

Keyboard shortcuts

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