Adding CLI Options¶
When adding or changing a CLI flag, multiple files need updating in lockstep. This checklist prevents drift between the CLI, Gradle plugin, GitHub Action, and npm wrapper.
Checklist¶
-
Define the option in
AlgorillaCommand.ktusing PicoCLI's@Optionannotation. Pick a long name (--my-flag), add a description, and set a default value. -
Wire it through in
CommandSupport.kt. Pass the value to the relevant reporter or engine component. If the option only affects console output, only pass it toConsoleReporter. -
Gradle plugin:
- Add a
Property<T>toAlgorillaExtension.kt - Add a matching task property to
AlgorillaTask.kt(with the appropriate@get:Inputannotation) - Set the convention (default) in
AlgorillaPlugin.ktand wire the extension property to the task
- Add a
-
GitHub Action (
action.yml):- Add an input with a default value
- Add the
INPUT_*env var to the "Run algorilla" step - Pass it to the CLI args (conditionally, if the default means "off")
-
Contract tests in
DistributionContractTest.kt:- Add the flag to the action contract list
- Add the flag to the Gradle contract list
- Add the flag to the npm passthrough list
-
CLI tests in
CliEndToEndTest.kt:- Add the flag to the
--helpassertion list - Add at least one end-to-end test exercising the new behavior
- Add the flag to the
-
User docs:
quickstart.mdCommon Options section (if user-facing)installation.mdGradle Plugin Configuration table- Relevant guide pages (e.g.
understanding-output.mdfor display-related options)
-
Verify
--helpshows the new flag with a clear description.
Tips¶
- Options that only affect display (like
--limit,--color) should not change exit codes or structured output (JSON/SARIF). - Use
defaultValuein the@Optionannotation so PicoCLI handles the default consistently. - Short aliases (e.g.
-ffor--format) are convenient but check for conflicts first —-lis already taken by--language.