config

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// COMMANDS is a top-level directive. Includes all commands to run.
	COMMANDS = "commands"
	SHELL    = "shell"
	ENV      = "env"
	EvalEnv  = "eval_env"
	MIXINS   = "mixins"
	VERSION  = "version"
	BEFORE   = "before"
)
View Source
var (
	ValidConfigDirectives = set.NewSet(
		COMMANDS, SHELL, ENV, EvalEnv, MIXINS, VERSION, BEFORE,
	)
	ValidMixinConfigDirectives = set.NewSet(
		COMMANDS, ENV, EvalEnv, BEFORE,
	)
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string
	// script to run
	Cmd string
	// script to run after cmd finished (cleanup, etc)
	After string
	// map of named scripts to run in parallel
	CmdMap map[string]string
	// if specified, overrides global shell for this particular command
	Shell string
	// if specified, overrides global workdir (where lets.yaml is located) for this particular command
	WorkDir     string
	Description string
	// env from command
	Env map[string]string
	// env from -E flag
	OverrideEnv map[string]string
	// store docopts from options directive
	Docopts     string
	SkipDocopts bool // default false
	Options     map[string]string
	CliOptions  map[string]string
	Depends     map[string]Dep
	// store depends commands in order declared in config
	DependsNames    []string
	ChecksumMap     map[string]string
	PersistChecksum bool

	// args with command name
	// e.g. from 'lets run --debug' we will get [run, --debug]
	Args []string
	// args without command name
	// e.g. from 'lets run --debug' we will get [--debug]
	CommandArgs []string

	// run only specified commands from cmd map
	Only []string
	// run all but excluded commands from cmd map
	Exclude []string

	// if command has declared checksum
	HasChecksum     bool
	ChecksumSources map[string][]string

	// ref is basically a command name to use with predefined args, env
	Ref string
	// can be specified only with ref
	RefArgs []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) FromRef

func (cmd Command) FromRef(refCommand Command) Command

func (*Command) GetPersistedChecksums

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

func (*Command) Help

func (cmd *Command) Help() string

func (Command) Pretty

func (cmd Command) Pretty() string

func (*Command) ReadChecksumsFromDisk

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

ReadChecksumsFromDisk reads all checksums for cmd into map.

func (Command) WithArgs

func (cmd Command) WithArgs(args []string) Command

func (Command) WithEnv

func (cmd Command) WithEnv(env map[string]string) Command

type Config

type Config struct {
	// absolute path to work dir - where config is placed
	WorkDir  string
	FilePath string
	Commands map[string]Command
	Shell    string
	// before is a script which will be included before every cmd
	Before  string
	Env     map[string]string
	Version string

	// absolute path to .lets
	DotLetsDir string
	// absolute path to .lets/checksums
	ChecksumsDir string
	// absolute path to .lets/mixins
	MixinsDir string
	// contains filtered or unexported fields
}

Config is a struct for loaded config file.

func NewConfig

func NewConfig(workDir string, configAbsPath string, dotLetsDir string) *Config

func NewMixinConfig

func NewMixinConfig(cfg *Config, configAbsPath string) *Config

func (*Config) CreateChecksumsDir added in v0.0.49

func (c *Config) CreateChecksumsDir() error

func (*Config) CreateMixinsDir added in v0.0.49

func (c *Config) CreateMixinsDir() error

type Dep

type Dep struct {
	Name string
	Args []string
	Env  map[string]string
}

Jump to

Keyboard shortcuts

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