cmd

package
v0.0.0-...-a041f96 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2014 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoVCS uint = iota
	Git
	Bzr
	Hg
	Svn
)
View Source
const (
	Blue   = "0;34"
	Red    = "0;31"
	Green  = "0;32"
	Yellow = "0;33"
	Cyan   = "0;36"
	Pink   = "1;35"
)

These contanstants map to color codes for shell scripts making them human readable.

Variables

View Source
var Quiet = false

Quiet, when set to true, can suppress Info and Debug messages.

Functions

func About

func About(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

About information for the CLI

func AddDependencies

func AddDependencies(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

AddDependencies adds a list of *Dependency objects to the given *Config.

This is used to merge in packages from other sources or config files.

func AlreadyGliding

func AlreadyGliding(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

AlreadyGliding emits a warning (and stops) if we're in a glide session.

This should be used when you want to make sure that we're not already in a glide environment.

func BeQuiet

func BeQuiet(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

BeQuiet supresses Info and Debug messages.

func Color

func Color(code, msg string) string

Color returns a string in a certain color. The first argument is a string containing the color code or a constant from the table above mapped to a code.

The following will print the string "Foo" in yellow:

fmt.Print(Color(Yellow, "Foo"))

func CowardMode

func CowardMode(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

CowardMode checks that the environment is setup before continuing on. If not setup and error is returned.

func Debug

func Debug(msg string, args ...interface{})

Debug logs debug information

func DropToShell

func DropToShell(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func ErrMsg

func ErrMsg(msg string, args ...interface{})

ErrMsg sends a message to Stderr

func Error

func Error(msg string, args ...interface{})

Error logs and error.

func ExecCmd

func ExecCmd(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func GetImports

func GetImports(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

GetImports iterates over the imported packages and gets them.

func GlideGopath

func GlideGopath(filename string) (string, error)

GlideGopath returns the GOPATH for a Glide project.

It determines the GOPATH by searching for the glide.yaml file, and then assuming the _vendor/ directory is in that directory. It traverses the tree upwards (e.g. only ancestors).

If no glide.yaml is found, or if a directory cannot be read, this returns an error.

func Godeps

func Godeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Godeps parses a Godeps file.

Params

  • dir (string): Directory root.

Returns an []*Dependency

func GodepsGit

func GodepsGit(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func GuessDeps

func GuessDeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

GuessDeps tries to get the dependencies for the current directory.

Params

  • dirname (string): Directory to use as the base. Default: "."

func GuessVCS

func GuessVCS(dep *Dependency) (uint, error)

GuessVCS attempts to guess guess the VCS used by a package.

func HasGodeps

func HasGodeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Indicates whether a Godeps file exists.

func In

func In(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Emits GOPATH for editors and such.

func InGopath

func InGopath(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func Info

func Info(msg string, args ...interface{})

Info logs information

func InitGlide

func InitGlide(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

InitGlide initializes a new Glide project.

Among other things, it creates a default glide.yaml.

func Into

func Into(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Into starts a new shell as a child of glide. This new shell inherits the environment typical of a Glide In, but without any shell export weirdness. Optionally, if a path is provided, this will glide into *that* directory.

PARAMS

  • into (string): The directory to glide into.

func LinkPackage

func LinkPackage(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func MergeToYaml

func MergeToYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Convert a Config object and a yaml.File to a single yaml.File.

Params:

  • conf (*Config): The configuration to merge.
  • overwriteImports (bool, default true): If this is true, old config will overwritten. If false, we attempt to merge the old and new config, with preference to the old.

Returns:

  • The root yaml.Node of the modified config.

Uses:

  • cxt.Get("yaml.File") as the source for the YAML file.

func Mkdir

func Mkdir(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func Msg

func Msg(msg string, args ...interface{})

Msg prints a message with optional arguments, that can be printed, of varying types.

func ParseYaml

func ParseYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

ParseYaml parses the glide.yaml format and returns a Configuration object.

Params:

  • filename (string): YAML filename as a string

Context:

  • yaml.File: This puts the parsed YAML file into the context.

Returns:

  • *Config: The configuration.

func ParseYamlString

func ParseYamlString(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func ReadyToGlide

func ReadyToGlide(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

ReadyToGlide fails if the environment is not sufficient for using glide.

Most importantly, it fails if glide.yaml is not present in the current working directory.

func Rebuild

func Rebuild(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Rebuild runs 'go build' in a directory.

Params:

  • conf: the *Config.

func SetReference

func SetReference(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

func Status

func Status(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Status is a command that prints the status of the glide and expected gopath.

func UpdateImports

func UpdateImports(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

UpdateImports iterates over the imported packages and updates them.

func UpdateReferences

func UpdateReferences(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

UpdateRevisions updates the revision numbers on all of the imports.

func VcsGet

func VcsGet(dep *Dependency) error

VcsGet figures out how to fetch a dependency, and then gets it.

Usually it delegates to lower-level *Get functions.

See https://code.google.com/p/go/source/browse/src/cmd/go/vcs.go

func VcsLastCommit

func VcsLastCommit(dep *Dependency) (string, error)

func VcsSetReference

func VcsSetReference(dep *Dependency) error

func VcsUpdate

func VcsUpdate(dep *Dependency) error

VcsUpdate updates to a particular checkout based on the VCS setting.

func VcsVersion

func VcsVersion(dep *Dependency) error

func Warn

func Warn(msg string, args ...interface{})

Warn logs a warning

func WriteYaml

func WriteYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

WriteYaml writes a yaml.Node to the console as a string.

Params:

  • yaml.Node: A yaml.Node to render.

Types

type BzrVCS

type BzrVCS struct{}

func (*BzrVCS) Get

func (b *BzrVCS) Get(dep *Dependency) error

func (*BzrVCS) LastCommit

func (b *BzrVCS) LastCommit(dep *Dependency) (string, error)

func (*BzrVCS) Update

func (b *BzrVCS) Update(dep *Dependency) error

func (*BzrVCS) Version

func (b *BzrVCS) Version(dep *Dependency) error

type Config

type Config struct {
	Name       string
	Imports    []*Dependency
	DevImports []*Dependency
	// InCommand is the default shell command run to start a 'glide in'
	// session.
	InCommand string
}

Config is the top-level configuration object.

func FromYaml

func FromYaml(top yaml.Node) (*Config, error)

FromYaml creates a *Config from a YAML node.

func (*Config) ToYaml

func (c *Config) ToYaml() yaml.Node

ToYaml returns a yaml.Map containing the data from Config.

type Dependency

type Dependency struct {
	Name, Reference, Repository string
	VcsType                     uint
	Subpackages                 []string
}

Dependency describes a package that the present package depends upon.

func DependencyFromYaml

func DependencyFromYaml(node yaml.Node) (*Dependency, error)

DependencyFromYaml creates a dependency from a yaml.Node.

func (*Dependency) ToYaml

func (d *Dependency) ToYaml() yaml.Node

ToYaml converts a *Dependency to a YAML Map node.

type GitVCS

type GitVCS struct{}

func (*GitVCS) Get

func (g *GitVCS) Get(dep *Dependency) error

GitGet implements the getting logic for Git.

func (*GitVCS) LastCommit

func (g *GitVCS) LastCommit(dep *Dependency) (string, error)

func (*GitVCS) Update

func (g *GitVCS) Update(dep *Dependency) error

func (*GitVCS) Version

func (g *GitVCS) Version(dep *Dependency) error

type GoGetVCS

type GoGetVCS struct{}

GoGetVCS implements a VCS for 'go get'.

func (*GoGetVCS) Get

func (g *GoGetVCS) Get(dep *Dependency) error

func (*GoGetVCS) LastCommit

func (g *GoGetVCS) LastCommit(dep *Dependency) (string, error)

LastCommit always retuns "" for GoGet, which is not revision-aware.

func (*GoGetVCS) Update

func (g *GoGetVCS) Update(dep *Dependency) error

func (*GoGetVCS) Version

func (g *GoGetVCS) Version(dep *Dependency) error

type HgVCS

type HgVCS struct{}

func (*HgVCS) Get

func (h *HgVCS) Get(dep *Dependency) error

hgGet implements the getting logic for hg.

func (*HgVCS) LastCommit

func (h *HgVCS) LastCommit(dep *Dependency) (string, error)

func (*HgVCS) Update

func (h *HgVCS) Update(dep *Dependency) error

func (*HgVCS) Version

func (h *HgVCS) Version(dep *Dependency) error

type SvnVCS

type SvnVCS struct{}

func (*SvnVCS) Get

func (s *SvnVCS) Get(dep *Dependency) error

svnGet implements the getting logic for svn.

func (*SvnVCS) LastCommit

func (s *SvnVCS) LastCommit(dep *Dependency) (string, error)

func (*SvnVCS) Update

func (s *SvnVCS) Update(dep *Dependency) error

func (*SvnVCS) Version

func (s *SvnVCS) Version(dep *Dependency) error

type VCS

type VCS interface {
	Get(*Dependency) error
	Update(*Dependency) error
	Version(*Dependency) error
	LastCommit(*Dependency) (string, error)
}

Jump to

Keyboard shortcuts

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