cmd

package
v0.0.0-...-df11fdc Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PkgTypeUnknown       = iota // 0
	PkgTypeGoRoot               // 1
	PkgTypeGloablGoPath         // 2
	PkgTypeProjectGoPath        // 3
	PkgTypeProjectVendor        // 4
)

Variables

View Source
var CmdAdd = cli.Command{
	Name:        "add",
	Usage:       "Add one or more new dependency packages",
	Description: `Add one or more new dependency packages`,
	Action:      runAdd,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
		cli.BoolFlag{
			Name:  "test, t",
			Usage: "include test files",
		},
		cli.StringFlag{
			Name:  "tags",
			Usage: "tags for import package find",
		},
	},
}

CmdAdd represents add a new dependency package and it's dependencies to this project

View Source
var CmdBuild = cli.Command{
	Name:            "build",
	Usage:           "Build the target",
	Description:     `Build the target`,
	Action:          runBuild,
	SkipFlagParsing: true,
}

CmdBuild represents

View Source
var CmdConfig = cli.Command{
	Name:        "config",
	Usage:       "Config global options",
	Description: `Config global options`,
	Subcommands: []cli.Command{
		{
			Name:        "get",
			Usage:       "Get global config options",
			Description: `Get global config options`,
			Action:      runConfigGet,
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "all, a",
					Usage: "Show all the config options",
				},
			},
		},
		{
			Name:        "set",
			Usage:       "Set global config options",
			Description: `Set global config options`,
			Action:      runConfigSet,
		},
	},
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
	},
}

CmdConfig represents config the gop global options

View Source
var CmdDownload = cli.Command{
	Name:        "dl",
	Usage:       "Download one or more packages",
	Description: `Download one or more packages`,
	Action:      runDownload,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "override, o",
			Usage: "Download packages even it exists.",
		},
		cli.BoolFlag{
			Name:  "recursive, r",
			Usage: "Also download all the dependent packages",
		},
		cli.StringFlag{
			Name:  "source, s",
			Usage: "Download source",
		},
		cli.StringFlag{
			Name:  "target, t",
			Usage: "Download target directory",
		},
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
	},
}

CmdDownload represents download a package from github or gopm.io

View Source
var CmdEnsure = cli.Command{
	Name:        "ensure",
	Usage:       "Ensure all the dependent packages installed accroding target",
	Description: `Ensure all the dependent packages installed accroding target`,
	Action:      runEnsure,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
		cli.BoolFlag{
			Name:  "dry, d",
			Usage: "Dry run, print what would be done",
		},
		cli.BoolFlag{
			Name:  "get, g",
			Usage: "call go get to download the package if package is not in GOPATH",
		},
		cli.BoolFlag{
			Name:  "update, u",
			Usage: "call go get -u to update the package if package is exist in GOPATH",
		},
		cli.BoolFlag{
			Name:  "test, t",
			Usage: "include test files",
		},
		cli.StringFlag{
			Name:  "tags",
			Usage: "tags for import package find",
		},
	},
}

CmdEnsure represents

View Source
var CmdInit = cli.Command{
	Name:        "init",
	Usage:       "Init a new project",
	Description: `Init a new project`,
	Action:      runInit,
	Flags: []cli.Flag{
		cli.BoolTFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
		cli.StringFlag{
			Name:  "editor, e",
			Usage: "Generate specifial editor configuration. Could be vscode or blank with no editor support",
		},
	},
}

CmdInit represents

View Source
var CmdRelease = cli.Command{
	Name:            "release",
	Usage:           "Release the target according the gop.yml",
	Description:     `Release the target according the gop.yml`,
	Action:          runRelease,
	SkipFlagParsing: true,
}

CmdRelease represents

View Source
var CmdRemove = cli.Command{
	Name:        "rm",
	Usage:       "Remove one or more dependent packages",
	Description: `Remove one or more dependent packages`,
	Action:      runRemove,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
	},
}

CmdRemove represents

View Source
var CmdRun = cli.Command{
	Name:            "run",
	Usage:           "Run the target and monitor the source file changes",
	Description:     `Run the target and monitor the source file changes`,
	Action:          runRun,
	SkipFlagParsing: true,
}

CmdRun represents

View Source
var CmdStatus = cli.Command{
	Name:        "status",
	Usage:       "List the target's dependent packages",
	Description: `List the target's dependent packages`,
	Action:      runStatus,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
		cli.BoolFlag{
			Name:  "test, t",
			Usage: "include test files",
		},
		cli.StringFlag{
			Name:  "tags",
			Usage: "tags for import package find",
		},
	},
}

CmdStatus represents

View Source
var CmdTest = cli.Command{
	Name:            "test",
	Usage:           "Run the target test codes",
	Description:     `Run the target test codes`,
	Action:          runTest,
	SkipFlagParsing: true,
}

CmdTest represents

View Source
var CmdUpdate = cli.Command{
	Name:        "update",
	Usage:       "Update spcified vendor packages",
	Description: `Update spcified vendor packages`,
	Action:      runUpdate,
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Enables verbose progress and debug output",
		},
		cli.BoolFlag{
			Name:  "test, t",
			Usage: "include test files",
		},
		cli.StringFlag{
			Name:  "tags",
			Usage: "tags for import package find",
		},
		cli.BoolFlag{
			Name:  "full, f",
			Usage: "if update all dependent packages, default only missing packages",
		},
	},
}

CmdUpdate represents update a new dependency package and it's dependencies to this project

View Source
var CmdVet = cli.Command{
	Name:            "vet",
	Usage:           "Vet",
	Description:     `Vet`,
	Action:          runVet,
	SkipFlagParsing: true,
}

CmdVet represents a vet command

View Source
var (
	// Debug indicated whether it is debug mode
	Debug = false
)
View Source
var (
	ErrNotSupported = errors.New("The package path is not supported")
)
View Source
var (
	// GlobalCommandArgs global command args for external package setting
	GlobalCommandArgs []string
)
View Source
var (
	GlobalEnvs []string
)

Functions

func Copy

func Copy(src, dest string) error

Copy copies file from source to target path.

func CopyDir

func CopyDir(srcPath, destPath string, filters ...func(filePath string) bool) error

CopyDir copy files recursively from source to target directory.

The filter accepts a function that process the path info. and should return true for need to filter.

It returns error when error occurs in underlying functions.

func CopyPkg

func CopyPkg(globalGoPath, pkg, dstPath string, includeTest bool) error

CopyPkg copy package from sources

func Error

func Error(a ...interface{})

Error println content as an error information

func Errorf

func Errorf(format string, a ...interface{})

Errorf printf content as an error information

func Home

func Home() (string, error)

Home returns the home directory for the executing user.

This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

func IsDir

func IsDir(dir string) bool

IsDir returns true if given path is a directory, or returns false when it's a file or does not exist.

func IsExist

func IsExist(path string) bool

IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.

func IsGoRepoPath

func IsGoRepoPath(importPath string) bool

IsGoRepoPath returns true if package is from standard library.

func Printf

func Printf(format string, a ...interface{})

Printf printf content according the flag

func Println

func Println(a ...interface{})

Println println content according the flag

func StatDir

func StatDir(rootPath string, includeDir ...bool) ([]string, error)

StatDir gathers information of given directory by depth-first. It returns slice of file list and includes subdirectories if enabled; it returns error and nil slice when error occurs in underlying functions, or given path is not a directory or does not exist.

Slice does not include given path itself. If subdirectories is enabled, they will have suffix '/'.

Types

type Command

type Command struct {
	Env []string
	// contains filtered or unexported fields
}

Command represents a command with its subcommands or arguments.

func NewCommand

func NewCommand(args ...string) *Command

NewCommand creates and returns a new Git Command based on given command and arguments.

func (*Command) AddArguments

func (c *Command) AddArguments(args ...string) *Command

AddArguments adds new argument(s) to the command.

func (*Command) Run

func (c *Command) Run() (string, error)

Run executes the command in default working directory and returns stdout in string and error (combined with stderr).

func (*Command) RunInDir

func (c *Command) RunInDir(dir string) (string, error)

RunInDir executes the command in given directory and returns stdout in string and error (combined with stderr).

func (*Command) RunInDirBytes

func (c *Command) RunInDirBytes(dir string) ([]byte, error)

RunInDirBytes executes the command in given directory and returns stdout in []byte and error (combined with stderr).

func (*Command) RunInDirPipeline

func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error

RunInDirPipeline executes the command in given directory, it pipes stdout and stderr to given io.Writer.

func (*Command) RunInDirTimeout

func (c *Command) RunInDirTimeout(timeout time.Duration, dir string) ([]byte, error)

RunInDirTimeout executes the command in given directory with given timeout, and returns stdout in []byte and error (combined with stderr).

func (*Command) RunInDirTimeoutPipeline

func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error

RunInDirTimeoutPipeline executes the command in given directory with given timeout, it pipes stdout and stderr to given io.Writer.

func (*Command) RunTimeout

func (c *Command) RunTimeout(timeout time.Duration) (string, error)

RunTimeout executes the command in default working directory with given timeout, and returns stdout in string and error (combined with stderr).

func (*Command) String

func (c *Command) String() string

String implement stringer interface

type ConcatenateError

type ConcatenateError struct {
	Err    error
	Reason string
}

ConcatenateError describes the error of concate

func (ConcatenateError) Error

func (e ConcatenateError) Error() string

Error implement error interface

type Config

type Config struct {
	Targets []Target
}

Config gop.yml

type ErrExecTimeout

type ErrExecTimeout struct {
	Timeout time.Duration // seconds
	Command *Command
}

ErrExecTimeout error of executing timed out

func (ErrExecTimeout) Error

func (e ErrExecTimeout) Error() string

Error implement error interface

type GlobalConfig

type GlobalConfig struct {
	Init struct {
		DefaultEditor string `yaml:"default_editor"`
	} `yaml:"init"`

	Repos struct {
		DefaultDir string `yaml:"default_dir"`
	} `yaml:"repos"`

	Sources map[string]Source `yaml:"sources"`
}

func (*GlobalConfig) Get

func (g *GlobalConfig) Get(key string) string

func (*GlobalConfig) Set

func (g *GlobalConfig) Set(key, value string)

type Pkg

type Pkg struct {
	Name  string
	Type  PkgType
	Exist bool
}

func ListImports

func ListImports(gopath, importPath, projectRoot, srcPath, tags string, isTest bool) ([]Pkg, error)

ListImports list all the dependencies packages name

type PkgType

type PkgType int

type Source

type Source struct {
	UrlPrefix string `yaml:"url_prefix"`
	PkgPrefix string `yaml:"pkg_prefix"`
}

type Target

type Target struct {
	Name     string
	Dir      string
	Assets   []string
	Monitors []string
}

Target build target

Jump to

Keyboard shortcuts

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