Config reference
Config schema
#
Top-level directives:#
Versionkey: version
type: semver string
Specify minimum required lets
version to run this config.
Example:
#
Shellkey: shell
type: string
required: true
Specify shell to use when running commands
Example:
#
Global envkey: env
type: map string => string or map with execution mode
Specify global env for all commands.
Env can be declared as static value or with execution mode:
Example:
#
Global eval_envDeprecated
key: eval_env
type: mapping string => string
Since
env
now hassh
execution mode,eval_env
is deprecated.
Specify global eval_env for all commands.
Example:
#
Global beforekey: before
type: string
Specify global before script for all commands.
Example:
Run redis
with docker-compose using log level ERROR
#
Mixinskey: mixins
type: list of string
Allows to split lets.yaml
into mixins (mixin config files).
To make lets.yaml
small and readable it is convenient to split main config into many smaller ones and include them
Example:
And lets test
works fine.
#
Ignored mixinsIt is possible to specify mixin file which could not exist. It is convenient when you have git-ignored file where you write your own commands.
To make lets
read this mixin just add -
prefix to filename
For example:
Now if my.yaml
exists - it will be loaded as a mixin. If it is not exist - lets
will skip it.
#
Commandskey: commands
type: mapping
required: true
Mapping of all available commands
Example:
#
Command directives:description
#
key: description
type: string
Short description of command - shown in help message
Example:
cmd
#
key: cmd
Actual command to run in shell.
Can be either:
- a string (also a multiline string)
- an array of strings - it will allow to append all arguments passed to command as is (see bellow)
- a map of string => string - this will allow run commands in parallel
(experimental)
Example single string:
Example multiline string:
Example array of strings:
When run with cmd as array of strings:
the -v
will be appended, so the resulting command to run will be go test ./... -v
cmd
can be a map (it is experimental feature)
.
Example of map of string => string
There are two flags --only
and --exclude
you can use with cmd map.
There must be used before command name:
work_dir
#
key: work_dir
type: string
Specify work directory to run in. Path must be relative to project root. Be default command's workdir is project root (where lets.yaml located).
Example:
shell
#
key: shell
type: string
Specify shell to run command in.
Any shell can be used, not only sh-compatible, for example python
.
Example:
after
#
key: after
type: string
Specify script to run after the actual command. May be useful, when we want to cleanup some resources or stop some services
after
script is guaranteed to execute if specified, event if cmd
exit code is not 0
Example:
depends
#
key: depends
type: array of string or array or object
Specify what commands to run before the actual command. May be useful, when you have one shared command.
For example, lets say you have command build
, which builds docker image.
Example:
build
command will be executed each time you run lets test
or lets fmt
#
Override arguments in depends commandIt is possible to override arguments or env for any commands declared in depends.
For example we want:
build
command to be executed with--verbose
flag in testdepends
.alarm
command to be executed withSomething is happening
arg andLEVEL: INFO
env in testdepends
.
Running lets test
will output:
options
#
key: options
type: string (multiline string)
One of the most cool things about lets
than it has built in docopt parsing.
All you need is to write a valid docopt for a command and lets will parse and inject all values for you.
More info http://docopt.org
When parsed, lets
will provide two kind of env variables:
LETSOPT_<VAR>
LETSCLI_<VAR>
How does it work?
Lets see an example:
So here we have:
args
- is a list of required positional args
--log-level
- is a key-value flag, must be provided with some value
--debug
- is a bool flag, if specified, means true, if no specified means false
In the env of cmd
command there will be available two types of env variables:
lets echo-env --log-level=info --debug one two three
Parsed and formatted key values
Raw flags (useful if for example you want to pass --debug
as is)
env
#
key: env
type: mapping string => string or map with execution mode
Env is as simple as it sounds. Define additional env for a command:
Env can be declared as static value or with execution mode:
Example:
eval_env
#
Deprecated
key: eval_env
type: mapping string => string
Since
env
now hassh
execution mode,eval_env
is deprecated.
Same as env but allows you to dynamically compute env:
Example:
Value will be executed in shell and result will be saved in env.
checksum
#
key: checksum
type: array of string | mapping string => array of string
Checksum used for computing file hashes. It is useful when you depend on some files content changes.
In checksum
you can specify:
- a list of file names
- a list of file regexp patterns (parsed via go
path/filepath.Glob
)
or
- a mapping where key is name of env variable and value is:
- a list of file names
- a list of file regexp patterns (parsed via go
path/filepath.Glob
)
Each time a command runs, lets
will calculate the checksum of all files specified in checksum
.
Result then can be accessed via LETS_CHECKSUM
env variable.
If checksum is a mapping, e.g:
Resulting env will be:
LETS_CHECKSUM_DEPS
- checksum of deps filesLETS_CHECKSUM_DOC
- checksum of doc filesLETS_CHECKSUM
- checksum of all checksums (deps and doc)
Checksum is calculated with sha1
.
If you specify patterns, lets
will try to find all matches and will calculate checksum of that files.
Example:
persist_checksum
#
key: persist_checksum
type: bool
This feature is useful when you want to know that something has changed between two executions of a command.
persist_checksum
can be used only if checksum
declared for command.
If set to true
, each run all calculated checksums will be stored to disk.
After each subsequent run lets
will check if new checksum and stored checksum are different.
Result of that check will be exposed via LETS_CHECKSUM_CHANGED
and LETS_CHECKSUM_[checksum-name]_CHANGED
env variables.
IMPORTANT: New checksum will override old checksum only if cmd has exit code 0
LETS_CHECKSUM_CHANGED
will be true after the very first execution, because when you first run command, there is no checksum yet, so we are calculating new checksum - that means that checksum has changed.
Example:
Resulting env will be:
LETS_CHECKSUM_DEPS
- checksum of deps filesLETS_CHECKSUM_DOC
- checksum of doc filesLETS_CHECKSUM
- checksum of all checksums (deps and doc)LETS_CHECKSUM_DEPS_CHANGED
- is checksum of deps files changedLETS_CHECKSUM_DOC_CHANGED
- is checksum of doc files changedLETS_CHECKSUM_CHANGED
- is checksum of all checksums (deps and doc) changed
ref
#
key: ref
type: string
Experimental feature
NOTE: ref
is not compatible (yet) with any directives except args
. Actually ref
is a special syntax that turns command into reference to command. It may be changed in the future.
Allows to run command with predefined arguments. Before this was implemented, if you had some commmand and wanted same command but with some predefined args, you had to use so called lets-in-lets
hack.
Before:
Now:
args
#
key: args
type: string
Experimental feature
args
is used only with ref and allows to set additional positional args to referenced command. See ref example.