Skip to main content

atmos.env

The atmos.env function runs atmos env through the current Atmos executable. Use it to read the variables from the env section of atmos.yaml as JSON, a dotenv file, shell exports, or GitHub Actions output.

Usage​

atmos.env(
*positionals,
flags = {},
args = [],
working_directory = ...,
env = ...,
output = "stream",
check = True,
)

Subcommands​

The env command has no subcommands. The bare call atmos.env() runs atmos env and prints the variables in bash format. Choose another format with the format flag. See the atmos env command reference for the complete list of flags.

Arguments​

*positionals

(Optional) Strings placed on the command line right after env. The command takes no positional arguments, so a call usually passes none.

flags

(Optional) A dictionary of command-line options; see flag translation. The format key becomes --format (shorthand f ) and accepts bash, json, dotenv, or github. The export key controls the export prefix in bash format, and output-file (shorthand o ) writes the result to a file.

args
(Optional) A list or tuple of strings appended after the flags.
working_directory, env, output, check

(Optional) See atmos.run for process options and defaults.

Options other than the positionals are keyword-only.

Returns​

A result with stdout, stderr, and exit_code. See atmos.run for output and error behavior.

Examples​

Read the variables as a dictionary​

result = atmos.env(flags = {"format": "json"}, output = "capture")
variables = json.decode(result.stdout)
for key in sorted(variables.keys()):
print(key)

Write a dotenv file​

atmos.env(flags = {"format": "dotenv", "output-file": ".env"})

This runs atmos env --format=dotenv --output-file=.env.

assignments = atmos.env(flags = {"export": False}, output = "capture")
print(assignments.stdout)

The False value becomes --export=false.