cmd

package
v0.0.0-...-94e1de0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2015 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cmd provides re-usable commands for Glide.

Index

Constants

View Source
const (
	NoVCS = ""
	Git   = "git"
	Bzr   = "bzr"
	Hg    = "hg"
	Svn   = "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 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 DeleteUnusedPackages

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

DeleteUnusedPackages removes packages from vendor/ that are no longer used.

func DropToShell

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

DropToShell executes a glide plugin. A command that's implemented by another application is executed in a similar manner to the way git commands work. For example, 'glide foo' would try to execute the application glide-foo. Params:

  • command: the name of the command to attempt executing.

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)

ExecCmd executes a system command inside vendor

func GPMGodeps

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

GPMGodeps parses a GPM-flavored Godeps file.

Params

  • dir (string): Directory root.

Returns an []*Dependency

func GPMGodepsGit

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

GPMGodepsGit reads a Godeps-Git file for gpm-git.

func Get

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

Get fetches a single package and puts it in vendor/.

Params:

  • package (string): Name of the package to get.
  • verbose (bool): default false

Returns:

  • *Dependency: A dependency describing this package.

func GetImports

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

GetImports iterates over the imported packages and gets them.

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 HasGPMGodeps

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

HasGPMGodeps indicates whether a Godeps file exists.

func HasGodepGodeps

func HasGodepGodeps(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.

Params:

  • filename (string): The name of the glide YAML file. Default is glide.yaml.
  • project (string): The name of the project. Default is 'main'.

func LinkPackage

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

LinkPackage creates a symlink to the project within the GOPATH.

func MergeToYaml

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

MergeToYaml converts 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)

Mkdir creates the src directory within the GOPATH.

func Msg

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

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

func NoVendor

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

NoVendor takes a path and returns all subpaths that are not vendor directories.

It is not recursive.

If the given path is a file, it returns that path unaltered.

If the given path is a directory, it scans all of the immediate children, and returns all of the go files and directories that are not vendor.

func NormalizeName

func NormalizeName(name string) (string, string)

NormalizeName takes a package name and normalizes it to the top level package.

For example, golang.org/x/crypto/ssh becomes golang.org/x/crypto. 'ssh' is returned as extra data.

func ParseGodepGodeps

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

Parse the Godep Godeps.json file.

Params: - dir (string): the project's directory

Returns an []*Dependency

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)

ParseYamlString parses a YAML string. This is similar but different to ParseYaml that parses an external file.

Params:

  • yaml (string): YAML as a string.

Returns:

  • *Config: The configuration.

func PathString

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

Take a list of paths and print a single string with space-separated paths.

func PrintName

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

PrintName prints the name of the project.

This comes from Config.Name.

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 Recurse

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

Recurse does glide installs on dependent packages. Recurse looks in all known packages for a glide.yaml files and installs for each one it finds.

func SetReference

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

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)

UpdateReferences updates the revision numbers on all of the imports.

func VcsExists

func VcsExists(dep *Dependency, dest string) bool

func VcsGet

func VcsGet(dep *Dependency, dest string) error

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

VcsGet installs into the dest.

func VcsLastCommit

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

func VcsUpdate

func VcsUpdate(dep *Dependency, vend string, force bool) error

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

func VcsVersion

func VcsVersion(dep *Dependency, vend string) error

func VendorPath

func VendorPath(c cookoo.Context) (string, error)

Return the path to the vendor directory.

func VersionGuard

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

VersionGuard ensures that the Go version is correct.

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 (yaml.Node): A yaml.Node to render.
  • out (io.Writer): An output stream to write to. Default is os.Stdout.
  • filename (string): If set, the file will be opened and the content will be written to it.

Types

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) HasDependency

func (c *Config) HasDependency(name string) bool

HasDependency returns true if the given name is listed as an import or dev import.

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                     string
	Subpackages, Arch, Os       []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) GetRepo

func (d *Dependency) GetRepo(dest string) (v.Repo, error)

func (*Dependency) ToYaml

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

ToYaml converts a *Dependency to a YAML Map node.

type GodepDependency

type GodepDependency struct {
	ImportPath string
	Comment    string `json:",omitempty"` // Description of commit, if present.
	Rev        string // VCS-specific commit ID.
}

GodepDependency is a modified version of Godep's Dependency struct. It drops all of the unexported fields.

type Godeps

type Godeps struct {
	ImportPath string
	GoVersion  string
	Packages   []string `json:",omitempty"` // Arguments to save, if any.
	Deps       []GodepDependency
	// contains filtered or unexported fields
}

The Godeps struct from Godep.

https://raw.githubusercontent.com/tools/godep/master/dep.go

We had to copy this because it's in the package main for Godep.

Jump to

Keyboard shortcuts

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