Skip to content

fix(cli): a short flag never means another tool option #5229

Done

Description

@dan-petty

Problem Description

Some wrappers give a short flag to one option, but the wrapped tool uses the same short flag for another option. An agent that knows the tool gets no usage error, only a wrong result, so the usage-error records cannot find these cases. ADR 0026 (#5223) says that a devops command takes the names of its tool.

devops command devops short flag Meaning in the tool
devops scan trivy -t is --type, -f is the devops render trivy: -t is --template, -f is the report format
devops test run -c is --changed pytest: -c is the config file
devops test load -s is --summary-export k6: -s is --stage
devops k8s stream-logs -t is --tail stern: -t is --timestamps
devops gh pages builds, devops gh metrics -l is --limit gh: -l is --label, -L is --limit

Reproduction Steps

  1. Run uv run devops k8s stream-logs --help. The output shows --tail -t.
  2. Read the flag table of stern (github.com/stern/stern). It shows -t, --timestamps.
  3. devops k8s stream-logs <query> -t 50 shows 50 lines of history. stern <query> -t adds timestamps.

Expected vs Actual Behavior

Expected: a short flag of a wrapper has the meaning that the wrapped tool gives it, or the wrapper has no such short flag. Actual: the six commands of the table give the short flag another meaning.

Environment Diagnostics

  • DevOps CLI Version: 0.122.0 (origin/main fe6b88f)
  • Python Version: 3.14
  • OS & Architecture: Linux x86_64
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

$ uv run devops scan trivy --help    # --type -t, --format -f
$ uv run devops test run --help      # --changed -c
$ uv run devops test load --help     # --summary-export -s
$ uv run devops k8s stream-logs --help   # --tail -t
$ uv run devops gh pages builds --help   # --limit -l

Proposed Fix

Remove each short flag of the table. The long names stay. Record the short flags of trivy, pytest, k6 and stern at the versions that the project installs, in the form of the recorded flags of #5223. Extend the check of #5223 to the composites that wrap one of these tools: a short flag of the command must not be a short flag of the tool with another meaning. Correct each document that uses a removed short flag.

Existing Tool Considered

Click options and the recorded flags of #5223. Nothing new is built.

Acceptance Criteria

  • The --help of the six commands shows no short form for these options.
  • The extended check fails on a test command that maps -t to an option other than the stern option.
  • devops docs check passes.

Dependencies

Merge first: #6597. Open the pull request after the pull request of #4840 merges, and not while another open pull request changes commands/gh.py.

Source: #4833

Alternatives check of 2026-11-29: none.
Tool: none found.
Reason: Searches found no open tool that records a wrapped tool's short flags or compares a wrapper command's short flags with the wrapped tool's meanings. Click and Typer only declare a command's own options, so the versioned record and collision check must be built.

Lacks:

  • No record of trivy, pytest, k6, stern or gh short flags
  • No cross-tool comparison of a wrapper short flag with the tool's meaning
  • No check over the declared options of a Typer command tree

Proposed design

Problem statement

Remove the conflicting short flags from five wrapper commands and add a collision check. Some wrappers give a short flag to an option that the wrapped tool uses for another option, so an agent that knows the tool gets a wrong result and no usage error. devops gh pages builds no longer exists, so the change covers devops gh metrics only. Merge #4840 first. Do not open the pull request while another open pull request changes src/devops_cli/commands/gh.py.

Acceptance criteria

Requirement: Wrapper help omits the conflicting short flags

Each wrapper command of the change SHALL declare no short form for its conflicting options.

Scenario: Help of the five wrapper commands

  • WHEN A test runs the help of scan trivy, test run, test load, k8s stream-logs and gh metrics through the Typer CLI runner.
  • THEN scan trivy shows --type and --format with no short form, test run shows --changed with no -c, test load shows --summary-export with no -s, k8s stream-logs shows --tail with no -t, and gh metrics shows --limit with no -l.

Requirement: The record holds the tool versions, the tool flags and the command tools

The record in src/devops_cli/core/tool_short_flags.py SHALL name the version of each wrapped tool, hold the short flags that the tool defines with their long options, and name the tool that each wrapper command wraps.

Scenario: Recorded flags of trivy, pytest, k6, stern and gh

  • WHEN A test imports the record.
  • THEN The record names the five tools with a version for each, maps -t to trivy --template, -f to trivy --format, -c to pytest --config-file, -s to k6 --stage, -t to stern --timestamps, -n to stern --namespace, -l to gh --label and -L to gh --limit, and names the tool of each of the five commands.

Requirement: A short flag with a different tool option fails the check

The collision check MUST report a collision when the record maps a wrapper short flag to a long option other than the one that the tool gives that short flag.

Scenario: Fixture maps -t to --tail

  • WHEN A test runs the check on a fixture command that maps -t to --tail for stern, while the record maps stern -t to --timestamps.
  • THEN The check reports one collision for -t on that command.

Requirement: A short flag with the tool's meaning passes the check

The collision check SHALL report no collision when the record maps the command's short flag to the long option that the tool gives that short flag.

Scenario: Fixture maps -n to --namespace

  • WHEN A test runs the check on a fixture command that maps -n to --namespace for stern.
  • THEN The check reports no collision for that command.

Requirement: A short flag with the tool's long name but another meaning fails

The collision check MUST report a collision when a wrapper command declares a short flag that the tool defines and the record maps that short flag to no tool option.

Scenario: Fixture maps -f to the devops render format

  • WHEN A test runs the check on a fixture command that declares --format with -f for the devops render format, while trivy defines -f as --format.
  • THEN The check reports one collision for -f on that command.

Requirement: The current wrapper commands pass the check

The collision check SHALL report no collision for the five wrapper commands after the conflicting short flags are removed.

Scenario: The five commands pass

  • WHEN A test runs the check on scan trivy, test run, test load, k8s stream-logs and gh metrics.
  • THEN The check reports no collision for any of the five commands.

Requirement: The generated command reference shows the long options

The generated command reference SHALL show the long options of the five commands without the removed short forms.

Scenario: The docs check passes after generation

  • WHEN uv run devops docs generate runs, and then uv run devops docs check runs.
  • THEN uv run devops docs check exits 0.

Existing Tool Considered

No open, maintained tool or library covers the need. The alternatives check of 2026-11-19 in the issue body gives the verdict none: Typer and Click declare a command's options and short flags, but neither keeps a record of a wrapped tool's flags nor runs a cross-tool collision check. The change keeps Typer for the command tree and adds a versioned flag record and a collision check on top of it. Written cost: about 120 lines of check code and about 180 lines of tests, about 6,000 tokens and about 3 hours to build, keep and fix.

Key questions

  • Which ADR governs the short flags of a wrapper command?: ADR 0037, 'Tool commands mirror and pass through options'. The body cites ADR 0026, which is 'GitHub settings are OpenTofu code the owner applies'. [sources: docs/adr/0037-tool-commands-mirror-and-pass-through-options.md]
  • Should a wrapper remove a conflicting short flag or remap it to the tool's meaning?: Remove the conflicting short flag and keep the long option. ADR 0037 requires a tool command to take the options of the tool. (best practice) [sources: docs/adr/0037-tool-commands-mirror-and-pass-through-options.md, openspec/changes/archive/2026-11-25-5318-tf-passthrough-flags/proposal.md, openspec/specs/tf-passthrough/spec.md]
    • Chosen: Remove the short flag and keep the long option. ADR 0037 keeps the wrapper aligned with the tool. The feat(tf): pass flags to tofu; add import, state, show, force-unlock #5318 change removed colliding aliases from devops tf and kept its long options.
    • Rejected: Remap the short flag to the tool's meaning. It adds an option that the issue does not request and that devops does not own.
    • Rejected: Keep the short flag with a warning. A warning still lets an agent get a wrong result with no usage error.
  • How should the check learn the short flags of trivy, pytest, k6, stern and gh?: Record them in one versioned table in src/devops_cli/core/tool_short_flags.py, beside the check. The table names the version that the project installs. A comment says to record again when a pin changes. (best practice) [sources: src/devops_cli/core/passthrough.py, tests/support/openspec_recording.py]
    • Chosen: One versioned record beside the check. One table holds the versions, the tool short flags and the tool of each command. The check reads it and no test reads a manifest.
    • Rejected: Parse each tool --help at test time. The test would depend on network and upstream output, and CI may not have the k6 or stern binary.
    • Rejected: Hard-code the flags in each command module. It scatters one fact across modules and lets the record drift.
  • Should the check allow a wrapper short flag that means the same option as the tool's short flag?: Yes. The record lists the short flags that a command keeps with the tool's meaning. A declared short flag that the tool defines and that the record does not list fails. scan trivy -f goes, because the devops render format is not trivy's --format. (best practice) [sources: src/devops_cli/commands/scan.py, src/devops_cli/commands/test_cmd.py]
    • Chosen: List each kept short flag with the tool's long option. The check passes a short flag only when the record gives the same long option that the tool gives that short flag.
    • Rejected: Allow a short flag when the long option names are equal. scan trivy --format and trivy --format have the same name but different meanings. This rule would keep -f.
    • Rejected: Reject every short flag that the tool defines. It would remove a safe alias that means the tool's own option, such as stern -n.
  • Should the record include the gh short flags?: Yes. devops gh metrics has -l for --limit, but gh gives -l to --label and -L to --limit. The check cannot reject gh metrics -l without the gh record. (best practice) [sources: src/devops_cli/commands/gh.py]
    • Chosen: Include gh in the record. The check can then compare gh metrics -l with gh -l --label and report the collision.
    • Rejected: Exclude gh from the record. The check cannot prove that gh metrics -l is wrong.
  • Does devops gh pages builds still exist?: No. The devops gh pages group holds status and verify. The command with the -l collision is devops gh metrics. [sources: src/devops_cli/commands/gh.py]
  • How should the check walk the commands and compare short flags?: Walk the Typer command tree and read each command's declared short flags. Do not parse help text. Do not hard-code the options. (best practice) [sources: src/devops_cli/commands/init.py, src/devops_cli/commands/gh.py, src/devops_cli/commands/test_cmd.py, src/devops_cli/commands/scan.py]
    • Chosen: Walk the Typer command tree. Typer holds each command's options and short flags. The check reads them from the commands themselves.
    • Rejected: Parse each command's --help text. The text changes with formatting and misses a command that a test does not call.
    • Rejected: Hard-code each command's options in the check. The check would drift from the command definitions.
  • Does the tree hold the feat(cli): tool commands pass unknown arguments to the tool #5223 tool flag record or collision check?: No. The tree holds ADR 0037 and the pass-through registry, but no record of a wrapped tool's short flags and no collision check. This change adds both rather than extending an existing one. [sources: src/devops_cli/core/passthrough.py, docs/adr/0037-tool-commands-mirror-and-pass-through-options.md, src/devops_cli/commands/scan.py, src/devops_cli/commands/test_cmd.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4840

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/bug
    scope/cli
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 90a3d2a while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/commands/gh.py.

  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • Click Typer lint option short flag conflict check library, results: 5
    • Python library detect CLI short flag collision between wrapper and wrapped tool, results: 5
    • github "short flag" collision check cli options tool, results: 5
    • CLI linter checks conflicting short options across commands, results: 5
    • Typer CLI options short names duplicate parameter documentation, results: 5
    • Click Python duplicate option declarations error same parameter name, results: 5
    • "click-lint" OR "cli-lint" python package flags, results: 5
    • pypi typer package, results: 5
    • click.pallets documentation, results: 5
    • typer, results: 5

    Sources:

  7. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  8. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  9. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  10. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  11. added
    status/ready
    and removed
    status/new
    on Nov 28, 2026
  12. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  13. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  14. removed
    status/in-review
    on Nov 29, 2026
  15. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/clisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions