CLI Extension Guide
Use this guide when adding, renaming, or moving oooconf commands. The goal is to keep the Unix and PowerShell entrypoints stable while extending the shared command model in one predictable place.
Source of Truth#
The public CLI is split across a small set of files:
| Area | File(s) | Notes |
|---|---|---|
| Command/completion metadata | scripts/cli/oooconf-cli-spec.toml |
Versioned recursive tree used by validation, completions, and generated reference docs. |
| Top-level Unix dispatch | scripts/setup/ooodnakov.sh and scripts/setup/lib/oooconf-dispatch.sh |
Parses global flags, normalizes command aliases, and calls command handlers. |
| Top-level PowerShell dispatch | scripts/setup/ooodnakov.ps1 and scripts/setup/lib/oooconf-dispatch.ps1 |
Mirrors Unix behavior for Windows and PowerShell users. |
| Command implementation modules | scripts/setup/lib/oooconf-*.sh and scripts/setup/lib/oooconf-*.ps1 |
Focused command families such as shell, color, wm, bar, help, and UI helpers. |
| Setup command modules | scripts/setup/lib/setup-*.sh and scripts/setup/lib/setup-*.ps1 |
Installer, links, optional dependency, doctor, completion, and summary helpers called by setup entrypoints. |
| Generated completions | home/.config/ooodnakov/zsh/completions/_oooconf and home/.config/ooodnakov/completions/oooconf-completions.ps1 |
Regenerate these; do not hand-edit generated output. |
| Autogen tool completions | scripts/generate/tool-completions.toml and scripts/generate/generate_tool_completions.py |
Typed third-party zsh completion manifest; use argv arrays and filters instead of shell strings. |
Add or Change a Command#
-
Add the command to the CLI spec. - Edit
scripts/cli/oooconf-cli-spec.toml. - Add top-level commands under[commands.<name>]. - Add nested commands under[commands.<parent>.subcommands.<child>]. - Give every node a unique, stablehandler_idand a non-emptyplatformslist. - Adddescription,options,values,value_set,option_value_sets, orcompleterson the command node that owns them. -
Implement dispatch on both supported shells. - For setup-style commands, prefer routing through
Invoke-SetupCommand/exec_setup_commandso global flags such as--dry-run,--skip-deps, and--yes-optionalkeep consistent behavior. - For command families with local logic, add focused handlers to mirroredscripts/setup/lib/oooconf-<area>.shandscripts/setup/lib/oooconf-<area>.ps1modules, then call those handlers from the top-levelswitch/casein the entrypoint. - Keep public entrypoints thin. Avoid moving large command bodies back intoscripts/setup/ooodnakov.sh,scripts/setup/ooodnakov.ps1,scripts/setup/setup.sh, orscripts/setup/setup.ps1. -
Update help text. - Add examples and command-specific help to
scripts/setup/lib/oooconf-help.shandscripts/setup/lib/oooconf-help.ps1. - Verifyoooconf --helpandoooconf help <command>stay useful for the new command and its nested commands. -
Regenerate completions. - Run
uv run python scripts/cli/generate_oooconf_completions.pyforoooconfcommand metadata. - Runuv run python scripts/generate/generate_tool_completions.pyafter changing third-party tool completion metadata. - Commit regenerated trackedoooconfZsh and PowerShell files when they change; autogen tool outputs underzsh/completions/autogen/stay local. - Runuv run python scripts/cli/generate_cli_reference.pyand commitdocs/cli-reference.md. -
Update documentation when behavior changes. - Update
README.mdfor user-facing command changes. - Updatedocs/architecture.mdfor layout or responsibility changes. - Updatedocs/reproducibility.mdwhen setup, install, lock, or generated-artifact behavior changes. - Updatecontributing.mdfor validation or workflow changes. - UpdateAGENTS.mdfor policy-level behavioral changes.
Command Metadata Patterns#
Use these TOML patterns in scripts/cli/oooconf-cli-spec.toml:
[commands.example]
description = "run an example workflow"
handler_id = "oooconf.example"
platforms = ["linux", "macos", "windows"]
options = { "--dry-run" = "preview actions without changing files" }
values = { "status" = "show status", "apply" = "apply changes" }
For nested commands:
[commands.example.subcommands.status]
description = "show example status"
handler_id = "oooconf.example.status"
platforms = ["linux", "macos", "windows"]
[commands.example.subcommands.apply]
description = "apply example changes"
handler_id = "oooconf.example.apply"
platforms = ["linux", "macos", "windows"]
options = { "--force" = "overwrite existing values" }
For shared dynamic values, prefer definitions instead of duplicating lists:
[definitions.example_modes]
fast = "fast mode"
safe = "safe mode"
[commands.example.subcommands.mode]
description = "set example mode"
handler_id = "oooconf.example.mode"
platforms = ["linux", "macos", "windows"]
value_set = "example_modes"
Spec Version and Migration Policy#
The [meta] table contains schema_version and minimum_reader_version.
Additive metadata changes keep the current schema version. Increment
schema_version for a changed contract; only increment minimum_reader_version
when older generators cannot safely interpret the file. Update the parser,
generators, contract tests, this policy, and generated artifacts in the same commit.
Readers fail clearly when minimum_reader_version exceeds their supported version.
Handler IDs are durable automation identifiers: do not rename or reuse one without
a documented compatibility migration.
Cross-Platform Checklist#
Before opening a PR for CLI changes, check the following:
- The command exists in
scripts/cli/oooconf-cli-spec.toml. - Unix and PowerShell dispatch both recognize the command or intentionally report it as unsupported.
- Help text exists for every new public command and important subcommand.
- Generated completions include the new command, options, and values.
- Tests include syntax coverage for touched shell files and completion/spec coverage for metadata changes.
- User-facing docs mention behavior that affects installation, setup, or day-to-day command usage.
Validation Commands#
Run the smallest relevant set for your change, and prefer the full set before merging larger CLI refactors:
bash -n scripts/setup/setup.sh
bash -n scripts/setup/ooodnakov.sh
bash -n scripts/setup/delete.sh
bash -n scripts/setup/minimal-setup.sh
bash -n scripts/setup/lib/*.sh
uv run python scripts/cli/generate_oooconf_completions.py
uv run python scripts/cli/generate_cli_reference.py
uv run python scripts/generate/generate_tool_completions.py --dry-run
uv run pytest tests/test_cli_contract.py tests/test_recursive_completions.py tests/test_static_smoke.py tests/test_optional_deps.py
If pwsh is available, also run:
./tests/test_powershell.ps1