secenv(1)
# Name
secenv - env-exec using SOPs files
# Synopsis
*secenv* [options] [envfiles] -- [cmd arg...]
# Description
secenv is used to run commands with specific environment variables, similar to
env. It loads environment variables as key-value pairs from SOPS-encrypted JSON
or YAML files. Values from the files can be inserted into command lines using
CLI templating (*-T*).
# Options
*-T*
Template arguments using Go templates. See secenv(1) for template
information.
*-t*=FMT
Set the SOPS file format (only json and yaml are currently supported).
Defaults to inferring from the file's extension.
*-i*
Drop the current process environment and only set variables found in
envfiles.
*-n*
Do not set env vars for values found in the env file. This can be set
alongside -T to only set values via CLI
argument templating.
## Templating
Templates use Go text/template to expand CLI arguments when the *-T* option is
set. Functions from sprig are available for formatting data.
In addition, there are three additional template functions for turning a single
CLI argument into multiple arguments:
*take* vals...
Take one or more values and turn them into individual CLI arguments. The
current CLI argument's final value will be dropped from the command line.
*drop* vals...
Drop the final value of the current CLI argument from the command line.
Any value passed to drop is ignored.
*exit* vals...
Drop the final value of the current CLI argument from the command line
and stop processing CLI arguments.
For example, to turn every value in the parsed env file(s) into --arg=value
command line arguments, you can use the following:
```
$ secenv -T -n env.json -- \\
echo '{{ range $k, $v := . }}{{ printf "--%v=%v" $k $v | take }}{{ end }}'
```