command

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChecksumName = "lets_default_checksum"

Variables

View Source
var (
	CMD             = "cmd"
	DESCRIPTION     = "description"
	ENV             = "env"
	EvalEnv         = "eval_env"
	OPTIONS         = "options"
	DEPENDS         = "depends"
	CHECKSUM        = "checksum"
	PersistChecksum = "persist_checksum"
)
View Source
var DocoptParser = &docopt.Parser{
	HelpHandler:   docopt.NoHelpHandler,
	OptionsFirst:  false,
	SkipHelpFlags: false,
}

Functions

func ChecksumForCmdPersisted added in v0.0.20

func ChecksumForCmdPersisted(dotLetsDir string, cmdName string) bool

ChecksumForCmdPersisted checks if checksums for cmd exists and persisted

func EvalEnvVariable

func EvalEnvVariable(rawCmd string) (string, error)

eval env value and trim result string TODO pass env from cfg.env - it will allow to use static env in eval_env TODO maybe use cfg.Shell instead of sh

func OptsToLetsCli

func OptsToLetsCli(opts docopt.Opts) map[string]string

func OptsToLetsOpt

func OptsToLetsOpt(opts docopt.Opts) map[string]string

func ParseAndValidateCommand

func ParseAndValidateCommand(newCmd *Command, rawCommand map[interface{}]interface{}) error

ParseAndValidateCommand parses and validates unmarshaled yaml

func ParseDocopts

func ParseDocopts(args []string, rawOptions string) (docopt.Opts, error)

ParseDocopts parses docopts for command options with args from os.Args TODO pass os.Argv explicitly

func PersistCommandsChecksumToDisk added in v0.0.20

func PersistCommandsChecksumToDisk(dotLetsDir string, cmd Command) error

Types

type Command

type Command struct {
	Name string
	// script to run
	Cmd string
	// map of named scripts to run in parallel
	CmdMap      map[string]string
	Description string
	// env from command
	Env map[string]string
	// env from -E flag
	OverrideEnv     map[string]string
	RawOptions      string
	Options         map[string]string
	CliOptions      map[string]string
	Depends         []string
	Checksum        string
	ChecksumMap     map[string]string
	PersistChecksum bool

	// prepared args - started from command name
	Args []string

	// run only specified commands from cmd map
	Only []string
	// run all but excluded commands from cmd map
	Exclude []string
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(name string) Command

NewCommand creates new command struct

func (*Command) ChecksumCalculator

func (cmd *Command) ChecksumCalculator(workDir string) error

func (*Command) GetPersistedChecksums added in v0.0.23

func (cmd *Command) GetPersistedChecksums() map[string]string

func (*Command) ReadChecksumsFromDisk added in v0.0.23

func (cmd *Command) ReadChecksumsFromDisk(dotLetsDir string, cmdName string, checksumMap map[string]string) error

ReadChecksumsFromDisk reads all checksums for cmd into map

type ParseCommandError

type ParseCommandError struct {
	Name string
	Path struct {
		Full  string
		Field string
	}
	Err error
}

func (*ParseCommandError) Error

func (e *ParseCommandError) Error() string

Jump to

Keyboard shortcuts

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