cmdutil

package
v1.3.9-279552a1d4fd1f5... Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAndExit

func ErrorAndExit(format string, args ...interface{})

ErrorAndExit errors with the given format and args, and then exits.

func Main

func Main(do func(interface{}) error, appEnv interface{}, decoders ...Decoder)

Main runs the common functionality needed in a go main function. appEnv will be populated and passed to do, defaultEnv can be nil if there is an error, os.Exit(1) will be called.

func ParseCommits

func ParseCommits(args []string) ([]*pfs.Commit, error)

ParseCommits takes a slice of arguments of the form "repo/commit-id" or "repo" (in which case we consider the commit ID to be empty), and returns a list of Commits

func Populate

func Populate(object interface{}, decoders ...Decoder) error

Populate populates an object with environment variables.

The environment has precedence over the decoders, earlier decoders have precedence over later decoders.

func Run

func Run(run func(args []string) error) func(*cobra.Command, []string)

Run makes a new cobra run function that wraps the given function.

func RunBoundedArgs

func RunBoundedArgs(min int, max int, run func([]string) error) func(*cobra.Command, []string)

RunBoundedArgs wraps a function in a function that checks its argument count is within a range.

func RunFixedArgs

func RunFixedArgs(numArgs int, run func([]string) error) func(*cobra.Command, []string)

RunFixedArgs wraps a function in a function that checks its exact argument count.

func RunIO

func RunIO(ioObj IO, args ...string) error

RunIO runs the command with the given IO and arguments.

func RunIODirPath

func RunIODirPath(ioObj IO, dirPath string, args ...string) error

RunIODirPath runs the command with the given IO and arguments in the given directory specified by dirPath.

func RunStdin

func RunStdin(stdin io.Reader, args ...string) error

RunStdin runs the command with the given stdin and arguments.

Types

type Decoder

type Decoder interface {
	Decode() (map[string]string, error)
}

Decoder decodes an env file.

type IO

type IO struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

IO defines the inputs and outputs for a command.

type RepeatedStringArg

type RepeatedStringArg []string

RepeatedStringArg is an alias for []string

func (*RepeatedStringArg) Set

func (r *RepeatedStringArg) Set(s string) error

Set adds a string to r

func (*RepeatedStringArg) String

func (r *RepeatedStringArg) String() string

func (*RepeatedStringArg) Type

func (r *RepeatedStringArg) Type() string

Type returns the string representation of the type of r

Jump to

Keyboard shortcuts

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