Skip to main content

ctx.args

The ctx.args value is a read-only list of the strings that follow the script file name on the command line.

Usage​

ctx.args

Returns​

A frozen list of strings. In a standalone script, it holds every token after the script file name, exactly as typed, including tokens such as --help or --config that look like Atmos options: everything after the script name belongs to the script. Atmos global flags such as --chdir=dir go before the script path and are not part of the list. In every other entry point, such as a custom command, workflow step, or hook, the list is empty.

A script that declares its interface with cli.command can still read the raw tokens here. The parsed values arrive in the arguments of its entry function.

Examples​

Require one argument​

examples/starlark-script/summarize.star

Run it with ./summarize.star services.json.

Handle a variable number of arguments​

#!/usr/bin/env atmos
if len(ctx.args) == 0:
fail("usage: ./check.star <stack>...")

for stack in ctx.args:
ui.info("Checking " + stack)
./check.star dev staging
▶ Checking dev
▶ Checking staging