Repository navigation
Description
Problem Description
Eight commands say in the help of --format that they accept csv, but each one refuses it. The help text is the literal Output format (table, json, yaml, csv): seven uses in src/devops_cli/commands/tf.py and one in src/devops_cli/commands/status_cmd.py. normalize_format in src/devops_cli/output/serialization.py accepts only the names of CONST_OUTPUT_FORMATS: json, table and yaml.
Reproduction Steps
- Run
uv run devops tf notify-plan --format csv.
Expected vs Actual Behavior
Expected: the help of --format names only the formats that the command accepts, so the help and the refusal agree.
Actual: the help names csv, and the command fails with Unknown output format 'csv'. Choose one of: json, table, yaml.
Environment Diagnostics
devops-cli at origin/main, 2026-11-12.
Logs, Traces, or Terminal Output
$ devops tf notify-plan --pr 42 --format csv
✗ Unknown output format 'csv'. Choose one of: json, table, yaml.
Existing tool considered
None. The help of these options can read the names from CONST_OUTPUT_FORMATS, or use the shared help text of the other commands.
Related
Related: #3644, which found it.
Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: fastapi/typer (https://github.com/fastapi/typer), MIT, last activity 2026-11-18, maintained.
Reason: Web searches surfaced no separate tool; Typer, the CLI framework the issue already names, renders an enum option as a choice list, refuses other values with exit 2, and records the usage error.
Covers:
- Enum option lists accepted values in --help
- Wrong value becomes a usage error with exit 2
- StrEnum member stays a str for resolve_format
Lacks:
- No yml alias and no case-insensitive match
- No shared CONST_OUTPUT_FORMATS value set
- No regeneration of the generated CLI docs
Proposed design
Problem statement
Eight commands name csv in the help of --format and refuse it with Unknown output format. The same shared help text also names markdown for commands that refuse it, and all 155 --format options are a plain str today. The help and the refusal come from two different places. The fix gives every --format option a Typer enum of the values that its command accepts, so the help names only accepted values and a wrong value exits 2.
Acceptance criteria
Requirement: Shared serialization format enum
The CLI MUST define the serialization output formats once as a StrEnum whose values are json, table, yaml and yml.
Scenario: The enum holds the constant values and the yml alias
- WHEN A test imports the shared output-format enum from
src/devops_cli/output/serialization.py - THEN Its values are
json,table,yamlandyml, and their set equalsCONST_OUTPUT_FORMATS | {'yml'}.
Requirement: Every format option is a choice
Every --format option of the CLI MUST take a Typer enum whose choices are the formats that its command accepts, not a plain str.
Scenario: No format option stays a plain string
- WHEN A test walks every command of the root Typer app and finds each
--formatparameter - THEN Each
--formatparameter has a parameter type with a non-emptychoicestuple, and no--formatoption help holdscsv.
Requirement: Eight commands name no csv
The eight commands that the issue names SHALL show only accepted values in the help of --format.
Scenario: The help of tf notify-plan and of status names no csv
- WHEN A test runs
CliRunnerondevops tf notify-plan --helpand ondevops status --help - THEN The output holds
[json|table|yaml|yml]and holds nocsv.
Requirement: A wrong value exits 2
A --format value outside the choices MUST exit 2 with the accepted values in the message.
Scenario: csv is a usage error
- WHEN A test runs
CliRunnerondevops tf notify-plan --plan-filewith a temporary plan file and--format csv - THEN The exit code is 2, the message holds the accepted values, and no
Unknown output formattext appears.
Requirement: No exit-1 format refusal
A wrong --format value MUST NOT reach normalize_format, so no command exits 1 with Unknown output format or Unsupported format.
Scenario: The usage error replaces the exit-1 refusal
- WHEN A test runs
CliRunnerondevops gh rate-limit --format jsnoand ondevops tf lint --format csv - THEN Each exit code is 2, and the output holds no
Unsupported formatand noUnknown output format.
Requirement: The accepted values stay
normalize_format MUST still accept every value that it accepts today.
Scenario: The yml alias and the case-insensitive match stay
- WHEN A test calls
normalize_format('YML')andnormalize_format('csv') - THEN The first call returns
yamland the second call raisesValidationErrorwith the accepted names.
Requirement: A format value keeps its case-insensitive match
A --format option that takes the shared serialization enum MUST accept a value in any case.
Scenario: An upper-case value is accepted
- WHEN A test runs
CliRunnerondevops tf lint --format JSON --dry-run - THEN The exit code is 0 and the output is JSON.
Requirement: The generated CLI docs are regenerated
The pull request that changes the --format help MUST regenerate the generated CLI docs, docs/CLI_REFERENCE.md, docs/commands/*.md and docs/MCP_TOOLS.md.
Scenario: The docs check reports no stale document
- WHEN
uv run devops ci --check --only docsruns - THEN It exits 0 and reports no stale generated document.
Existing Tool Considered
The alternatives check of 2026-11-15 found no separate external tool, but the project's CLI framework Typer 0.28.0 and its Click 8.5.1 (pyproject.toml:12-13) already cover the need: a Typer enum option renders as choice (completed|not-planned) in the docs (docs/commands/gh.md:649), refuses another value with exit 2, and the root group records it as bad_value. The project already uses IssueCloseReason(StrEnum) as an option type (src/devops_cli/commands/gh.py:1386 and :1411). The library lacks the project's yml alias and its CONST_OUTPUT_FORMATS list, which a small StrEnum in src/devops_cli/output/serialization.py supplies, and it does not regenerate docs/CLI_REFERENCE.md, docs/commands/*.md or docs/MCP_TOOLS.md, which uv run devops docs generate does. Cost: about 20 lines of enum definitions and one option-type edit in each command module, about 15k tokens to build, keep and fix, and 4 to 6 hours.
Key questions
- Which output formats does the CLI accept today?:
CONST_OUTPUT_FORMATSatsrc/devops_cli/config/constants.py:4795holdsjson,tableandyaml.normalize_formatatsrc/devops_cli/output/serialization.py:26lowercases the value, mapsymltoyaml, and raisesValidationErrorfor every other value. Commands that use other formats have their own checks, such astable/jsonatsrc/devops_cli/commands/gh.py:1577andtext/markdown/jsonatsrc/devops_cli/commands/ai.py:1795. [sources: src/devops_cli/config/constants.py:4795, src/devops_cli/output/serialization.py:26, src/devops_cli/commands/gh.py:1577, src/devops_cli/commands/ai.py:1795] - Where does the help text that names
csvcome from?: The literalOutput format (table, json, yaml, csv)is the help of seven--formatoptions insrc/devops_cli/commands/tf.py(lines 300, 475, 581, 764, 854, 917 and 981) and of one insrc/devops_cli/commands/status_cmd.py(line 109). Each of these commands callsresolve_formatand refusescsv. [sources: src/devops_cli/commands/tf.py:300, src/devops_cli/commands/tf.py:475, src/devops_cli/commands/tf.py:581, src/devops_cli/commands/tf.py:764, src/devops_cli/commands/tf.py:854, src/devops_cli/commands/tf.py:917, src/devops_cli/commands/tf.py:981, src/devops_cli/commands/status_cmd.py:109] - How should each
--formatoption declare the values that it accepts?: Each--formatoption takes a TyperStrEnumwhose members are the formats that its command accepts. The project already does this:IssueCloseReason(StrEnum)atsrc/devops_cli/commands/gh.py:1386is the type of--reasonat:1411, anddocs/commands/gh.md:649shows the help aschoice (completed|not-planned). The archived design records that Typer refuses another value with exit 2 and Click's message (openspec/changes/archive/2026-10-29-1658-issues-close-reason/design.md:23). AStrEnummember is astr, soresolve_formatkeeps its signature. A single sharedclick.ChoicefromCONST_OUTPUT_FORMATSwould refuse values that other commands accept today, such asmarkdown,text,dotandprometheus, and Typer 0.28 vendors Click astyper._click(src/devops_cli/core/cli.py:14), so a top-levelclick.Choiceis not the type that a Typer option takes. (best practice) [sources: src/devops_cli/commands/gh.py:1386, src/devops_cli/commands/gh.py:1411, docs/commands/gh.md:649, openspec/changes/archive/2026-10-29-1658-issues-close-reason/design.md:23, pyproject.toml:13, src/devops_cli/core/cli.py:14, src/devops_cli/commands/ai.py:1795, src/devops_cli/commands/ai_gateway.py:103, src/devops_cli/commands/k8s/cluster_context.py:416, src/devops_cli/commands/ai_ast.py:106, docs/MCP_TOOLS.md:273]- Chosen: A Typer
StrEnumfor each accepted value set. The project already usesIssueCloseReason(StrEnum)as an option type, and Typer renders it as a choice, refuses another value with exit 2, and the root group recordsbad_value; aStrEnummember is astr, soresolve_formatkeeps its signature. - Rejected: One shared
click.ChoicefromCONST_OUTPUT_FORMATS. The commands acceptmarkdown,text,dotandprometheusas well, and Typer 0.28 vendors Click astyper._click, so a top-levelclick.Choiceis not the type that a Typer option takes. - Rejected: A help text from the constant only. The help and the refusal stay two sources, and a wrong value still exits 1 with no usage error.
- Chosen: A Typer
- Should the shared format type keep the
ymlalias and the case-insensitive match?: Yes.normalize_formatlowercases the value and mapsymltoyamltoday, so the serialization enum has aYMLmember and each option that takes it accepts a value in any case. A list of the three constant names alone would refuse--format JSONand--format yml, which the CLI accepts today. (best practice) [sources: src/devops_cli/output/serialization.py:26, src/devops_cli/output/serialization.py:32]- Chosen: Keep the
ymlalias and the case-insensitive match. It keeps every value thatnormalize_formataccepts today,YMLandymlincluded. - Rejected: Use the exact names of
CONST_OUTPUT_FORMATS. It refuses--format JSONand--format yml, which work today.
- Chosen: Keep the
- How does a wrong
--formatvalue reach the usage-error record?: Click's choice conversion raisesBadParameter, aUsageError. The rootUsageRecordingGroupwrapsmake_contextandinvokein_recorded_usage_errors(src/devops_cli/core/cli.py:201), which callsrecord_usage_errorfor eachUsageError(src/devops_cli/core/cli.py:217)._classifiedmapsBadParametertoUsageErrorKind.BAD_VALUE(src/devops_cli/telemetry/usage_errors.py:186), so the ledger gets onebad_valuerecord with the option name. The change adds no recording code. [sources: src/devops_cli/core/cli.py:201, src/devops_cli/core/cli.py:217, src/devops_cli/telemetry/usage_errors.py:186, tests/telemetry/test_usage_errors.py:87] - How does the project keep the generated CLI docs correct?:
docs/CLI_REFERENCE.md,docs/commands/*.mdanddocs/MCP_TOOLS.mdare generated documents.uv run devops docs generatewrites them, and thedocsrow ofStatic Analysisrunsuv run devops ci --check --only docsand refuses a document that is not the output of its generator (CONTEXT.md:245,docs/ROUTINE_TASKS.md:33). [sources: CONTEXT.md:245, docs/ROUTINE_TASKS.md:33] - Does one pull request deliver the change?: Yes. The change is one enum per accepted value set, one edit per
--formatoption and the regenerated docs. It is mechanical, and no part waits on another item. (best practice) [sources: src/devops_cli/output/serialization.py, docs/CLI_REFERENCE.md]- Chosen: One pull request. The reply of 2026-11-13 asks for the docs regeneration in the same pull request, and the edit is mechanical.
- Rejected: Split by command group. It repeats the shared enums and leaves the help inconsistent between the groups.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(cli)scope of the title gives the scope.Help text inconsistency causes confusion but no functional failure.Corrects misleading help text without changing command behaviour.Edit help strings in two files to remove csv.Both concern output formats in the CLI, but #411 adds format support while this fixes help text that names an unsupported format.dan-petty commentedon Nov 13, 2026
New evidence of 2026-11-13 (review of failing CLI calls). I propose to fix the cause, not the help text.
--formatoptions are a plainstr, and the help shows<str>with no value names.normalize_format(src/devops_cli/output/serialization.py, near lines 26-40),src/devops_cli/commands/gh.py(near lines 1576-1577) andsrc/devops_cli/commands/pr.py(near line 653) refuse a wrong value with exit 1. For example,devops gh rate-limit --format jsnoexits 1 and makes no usage-error record. So nobody can count wrong values today.--jsonand--format json.Scope point: each
--formatoption uses one sharedclick.Choice(or a TyperEnum) with the formats that the command supports. Then:bad_valueusage error,Regenerate
docs/CLI_REFERENCE.mdin the same pull request, because the help of 155 options changes.Measure:
cli_usage_errorrecords of kindbad_valuefor--formatappear, and exit-1 "Unsupported format" errors go to 0.devops-cli-service commentedon Nov 15, 2026
Alternatives check: none
Reason: The searches for CLI option-choice/help tooling returned no relevant tool or library: the results were unrelated general pages, and nothing found addresses a project-internal help-string bug. The need is to make the
--formathelp insrc/devops_cli/commands/tf.pyandstatus_cmd.pyname only the formats thatnormalize_format/CONST_OUTPUT_FORMATSaccept, which is an edit of the project's own code (or reuse of the project's existing option types), not something an external tool covers.Tool: none found
Lacks:
--formathelp text in the project's own commandsCONST_OUTPUT_FORMATS/normalize_formatSearches run:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 21, 2026
The result in the alternatives block of the issue body changed. Before this check:
none, no tool. A person decides what the new result means for the item.Searches (4)
Tools considered:
Searches run:
Sources: