Documentation ¶
Overview ¶
Package cmd provides re-usable commands for Glide.
Index ¶
- Constants
- Variables
- func About(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func AddDependencies(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func BeQuiet(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Color(code, msg string) string
- func CowardMode(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Debug(msg string, args ...interface{})
- func DeleteUnusedPackages(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func DropToShell(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ErrMsg(msg string, args ...interface{})
- func Error(msg string, args ...interface{})
- func ExecCmd(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Flatten(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func GPMGodeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func GPMGodepsGit(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func GbManifest(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func GetAll(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func GetImports(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Gopath() string
- func Gopaths() []string
- func GuessDeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func HasGPMGodeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func HasGbManifest(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func HasGodepGodeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Info(msg string, args ...interface{})
- func InitGlide(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func LinkPackage(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ListDeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func MergeToYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Mkdir(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Msg(msg string, args ...interface{})
- func NoVendor(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func NormalizeName(name string) (string, string)
- func ParseGodepGodeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ParseYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ParseYamlString(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func PathString(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func PrintName(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func ReadyToGlide(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Rebuild(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func SetReference(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Tree(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func UpdateImports(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func UpdateReferences(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func VcsExists(dep *Dependency, dest string) bool
- func VcsGet(dep *Dependency, dest string) error
- func VcsLastCommit(dep *Dependency, vend string) (string, error)
- func VcsUpdate(dep *Dependency, vend string, force bool) error
- func VcsVersion(dep *Dependency, vend string) error
- func VendorPath(c cookoo.Context) (string, error)
- func VendoredCleanUp(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func VendoredSetup(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func VersionGuard(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- func Warn(msg string, args ...interface{})
- func WriteYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
- type BuildCtxt
- type Config
- type Dependencies
- type Dependency
- type GodepDependency
- type Godeps
Constants ¶
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 ¶
var IsDebugging = false
var Quiet = false
Quiet, when set to true, can suppress Info and Debug messages.
Functions ¶
func AddDependencies ¶
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 Color ¶
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 ¶
CowardMode checks that the environment is setup before continuing on. If not setup and error is returned.
func DeleteUnusedPackages ¶
DeleteUnusedPackages removes packages from vendor/ that are no longer used.
func DropToShell ¶
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 Flatten ¶
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 (*Config): The configuration.
Returns:
func GPMGodeps ¶
GPMGodeps parses a GPM-flavored Godeps file.
Params
- dir (string): Directory root.
Returns an []*Dependency
func GPMGodepsGit ¶
GPMGodepsGit reads a Godeps-Git file for gpm-git.
func GbManifest ¶
GbManifest
Params:
- dir (string): The directory where the manifest file is located.
Returns:
func GetAll ¶
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 GetImports ¶
GetImports iterates over the imported packages and gets them.
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 GuessDeps ¶
GuessDeps tries to get the dependencies for the current directory.
Params
- dirname (string): Directory to use as the base. Default: "."
func HasGPMGodeps ¶
HasGPMGodeps indicates whether a Godeps file exists.
func HasGbManifest ¶
func HasGodepGodeps ¶
HasGodepGodeps is a command to detect if a package contains a Godeps.json file.
func InitGlide ¶
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 ¶
LinkPackage creates a symlink to the project within the GOPATH.
func MergeToYaml ¶
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 Msg ¶
func Msg(msg string, args ...interface{})
Msg prints a message with optional arguments, that can be printed, of varying types.
func NoVendor ¶
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 ¶
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 ¶
ParseGodepGodeps parses the Godep Godeps.json file.
Params: - dir (string): the project's directory
Returns an []*Dependency
func ParseYaml ¶
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 ¶
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 ¶
Take a list of paths and print a single string with space-separated paths.
func ReadyToGlide ¶
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 SetReference ¶
SetReference is a command to set the VCS reference (commit id, tag, etc) for a project.
func UpdateImports ¶
UpdateImports iterates over the imported packages and updates them.
Params:
- force (bool): force packages to update (default false)
- conf (*Config): The configuration
- packages([]string): The packages to update. Default is all.
func UpdateReferences ¶
UpdateReferences updates the revision numbers on all of the imports.
If a `packages` list is supplied, only the given base packages will be updated.
Params:
- conf (*Config): Configuration
- packages ([]string): A list of packages to update. Default is all packages.
func VcsExists ¶
func VcsExists(dep *Dependency, dest string) bool
VcsExists checks if the directory has a local VCS checkout.
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)
VcsLastCommit gets the last commit ID from the given dependency.
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
VcsVersion set the VCS version for a checkout.
func VendorPath ¶
Return the path to the vendor directory.
func VendoredCleanUp ¶
VendoredCleanUp is a command that cleans up vendored codebases after an update. If enabled (via update) it removed the VCS info from updated vendored packages. This should be a suffix to UpdateImports and VendoredSetup should be a prefix to UpdateImports.
func VendoredSetup ¶
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 ¶
VersionGuard ensures that the Go version is correct.
Types ¶
type BuildCtxt ¶
BuildCtxt is a convenience wrapper for not having to import go/build anywhere else
func GetBuildContext ¶
GetBuildContext returns a build context from go/build. When the $GOROOT variable is not set in the users environment it sets the context's root path to the path returned by 'go env GOROOT'.
type Config ¶
type Config struct { Parent *Config Name string Imports Dependencies DevImports Dependencies // InCommand is the default shell command run to start a 'glide in' // session. InCommand string Flatten bool }
Config is the top-level configuration object.
func (*Config) HasDependency ¶
HasDependency returns true if the given name is listed as an import or dev import.
func (*Config) HasRecursiveDependency ¶
HasRecursiveDependency returns true if this config or one of it's parents has this dependency
type Dependencies ¶
type Dependencies []*Dependency
Dependencies is a collection of Dependency
func (Dependencies) DeDupe ¶
func (d Dependencies) DeDupe() (Dependencies, error)
DeDupe cleans up duplicates on a list of dependencies.
func (Dependencies) Get ¶
func (d Dependencies) Get(name string) *Dependency
Get a dependency by name
type Dependency ¶
type Dependency struct {
Name, Reference, Repository string
VcsType string
Subpackages, Arch, Os []string
UpdateAsVendored bool
Flatten bool
Flattened bool
}
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)
GetRepo retrieves a Masterminds/vcs repo object configured for the root of the package being retrieved.
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.