ctx.args
The ctx.args value is a read-only list of strings. In a standalone script they are the tokens that follow the
script file name on the command line. In a Git hook they are the arguments Git passes to the hook.
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 a Git hook, the list holds the arguments Git passes to the hook, such as the commit message file path for commit-msg or the remote name and URL for pre-push. In the other entry points, such as a custom command, workflow step, or lifecycle 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
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
Related
cli.commandparses arguments and flags into typed values.ctx.scriptnames the script file.ctxlists every context attribute.- Standalone CLI apps