cmd

package
v0.0.0-...-bb15701 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package cmd provides re-usable commands for Glide.

Index

Constants

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 IsDebugging = false
View Source
var NoColor = false
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 *cfg.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 CheckColor

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

CheckColor turns off the colored output (and uses plain text output) for logging depending on the value of the "no-color" flag.

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 EnsureCacheDir

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

EnsureCacheDir Creates the $HOME/.glide/cache directory (unless home is specified to be different) if it does not exist.

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 Flatten

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

Flatten recurses through all dependent packages and flattens to a top level.

Flattening involves determining a tree's dependencies and flattening them into a single large list.

Params:

  • packages ([]string): The packages to read. If this is empty, it reads all packages.
  • force (bool): force vcs updates.
  • conf (*cfg.Config): The configuration.

Returns:

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 []*cfg.Dependency

func GPMGodepsGit

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

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

func GbManifest

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

GbManifest

Params:

  • dir (string): The directory where the manifest file is located.

Returns:

func GetAll

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

GetAll gets zero or more repos.

This takes a package name, normalizes it, finds the repo, and installs it. It's the workhorse behind `glide get`.

Params:

  • packages ([]string): Package names to get.
  • verbose (bool): default false

Returns:

  • []*Dependency: A list of constructed dependencies.

func Gopath

func Gopath() string

Gopath gets GOPATH from environment and return the most relevant path.

A GOPATH can contain a colon-separated list of paths. This retrieves the GOPATH and returns only the FIRST ("most relevant") path.

This should be used carefully. If, for example, you are looking for a package, you may be better off using Gopaths.

func Gopaths

func Gopaths() []string

Gopaths retrieves the Gopath as a list when there is more than one path listed in the Gopath.

func GuardYaml

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

GuardYaml protects the glide yaml file from being overwritten.

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: "."
  • skipImport (book): Whether to skip importing from Godep, GPM, and gb

func HasGPMGodeps

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

HasGPMGodeps indicates whether a Godeps file exists.

func HasGbManifest

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

func HasGodepGodeps

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

HasGodepGodeps is a command to detect if a package contains a Godeps.json file.

func Info

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

Info logs information

func Install

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

Install installs the dependencies from a Lockfile.

func LinkPackage

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

LinkPackage creates a symlink to the project within the GOPATH.

func ListDeps

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

ListDeps lists all of the dependencies of the current project.

Params:

  • dir (string): basedir
  • deep (bool): whether to do a deep scan or a shallow scan

Returns:

func LoadLockFile

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

LoadLockFile loads the lock file to the context and checks if it is correct for the loaded cfg file.

func LockFileExists

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

LockFileExists checks if a lock file exists. If not it jumps to the update command.

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)

ParseGodepGodeps parses the Godep Godeps.json file.

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

Returns an []*cfg.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

Returns:

  • *cfg.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:

  • *cfg.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 *cfg.Config.

func SetReference

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

SetReference is a command to set the VCS reference (commit id, tag, etc) for a project.

func Tree

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

Tree prints a tree representing dependencies.

func UpdateImports

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

UpdateImports iterates over the imported packages and updates them.

Params:

  • force (bool): force packages to update (default false)
  • conf (*cfg.Config): The configuration
  • packages([]string): The packages to update. Default is all.

func VcsExists

func VcsExists(dep *cfg.Dependency, dest string) bool

VcsExists checks if the directory has a local VCS checkout.

func VcsGet

func VcsGet(dep *cfg.Dependency, dest, home string, cache, cacheGopath, useGopath bool) error

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

VcsGet installs into the dest.

func VcsLastCommit

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

VcsLastCommit gets the last commit ID from the given dependency.

func VcsUpdate

func VcsUpdate(dep *cfg.Dependency, vend, home string, force, cache, cacheGopath, useGopath bool) error

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

func VcsVersion

func VcsVersion(dep *cfg.Dependency, vend string) error

VcsVersion set the VCS version for a checkout.

func VendorPath

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

Return the path to the vendor directory.

func VendoredCleanUp

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

VendoredCleanUp is a command that cleans up vendored codebases after an update. If enabled (via update) it removes the VCS info from updated vendored packages. This should be a suffix to UpdateImports and VendoredSetup should be a prefix to UpdateImports.

func VendoredSetup

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

VendoredSetup is a command that does the setup for vendored directories. If enabled (via update) it marks vendored directories that are being updated and removed the old code. This should be a prefix to UpdateImports and VendoredCleanUp should be a suffix to UpdateImports.

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 WriteLock

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

WriteLock writes the lock as YAML.

Params:

  • lockfile: A *cfg.Lockfile to render.
  • out (io.Writer): An output stream to write to. Default is os.Stdout.

func WriteYaml

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

WriteYaml writes the config as YAML.

Params:

  • conf: A *cfg.Config 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 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