Skip to content

refactor(cli): command help and messages live with their command, and shared option help stays in lang #1007

Closed as not planned

Description

@dan-petty

Context & Rationale

Nearly every help string and message has one consumer, yet all of them live in two central files that every new command edits. Checked at 9c879ae.

  • lang/en/help.py: 963 strings in 42 frozen dataclasses, bound at 1,123 help=HELP.x.y sites, plus 375 inline help="..." literals that bypass the catalog. Of 657 referenced attributes, 587 (89%) are referenced from exactly one module; HELP.options (42 modules) and HELP.k8s (10) are the shared core.
  • lang/en/messages.py: 392 of 398 referenced attributes are single-module. lang/en/errors.py: 57 of 57.
  • main.py _COMMAND_SPECS is a second hand-maintained registry (39 entries, two with inline literal help).
  • A new command edits help.py twice (class and catalog field), messages.py twice, errors.py, _COMMAND_SPECS and the hand-picked asserts in tests/test_language_catalogs.py before any feature file. help.py is in 30 of the 63 release commits, messages.py in 23.
  • One language pack exists (en), so the localisation seam has one adapter.

Deletion test: delete help.py and 587 strings reappear in exactly one command module each; about 70 (options, shared k8s) reappear across 2 to 42 modules and earn the shared core.

Scope & Deliverables

Strategic Alignment

Scope added 2026-10-02: checked at 38517a8; the figures hold within a few percent. lang/en/help.py has 41 dataclasses, src has 1,129 help=HELP. sites and 375 help=" literals, and main.py's _COMMAND_SPECS has 38 entries. lang/__init__.py imports en with no locale selection, no setting selects a language, and no document names a localisation plan. The docs generator reads Click command metadata (docs/generator.py:255-260), not the catalog. _COMMAND_SPECS registers command groups lazily, so a group's help must be readable without importing its command module.

Acceptance criteria

  • Each command module owns frozen *Help and *Messages dataclasses for the strings only it uses. devops_cli.lang keeps the strings two or more modules use (HELP.options, the shared k8s help, general messages, persona titles) and the group help _COMMAND_SPECS needs.
  • An AST test fails on a help= literal in a Typer option, argument or command, and on a devops_cli.lang attribute that only one module uses. It replaces the hand-picked asserts in tests/test_language_catalogs.py.
  • _COMMAND_SPECS has no inline help literal.
  • devops docs generate output (docs/CLI_REFERENCE.md, docs/commands/*.md) is byte-identical before and after.
  • tests/test_all_commands_help_dryrun.py passes unchanged.
  • docs/ROUTINE_TASKS.md:28 and :104, which today send every user-facing string to lang/en/, state the placement rule: a string lives with its one consumer, or in lang once two modules use it. AGENTS.md has no help-placement rule at 38517a8 and gains one only if #docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 words its rule to cover lang too.
  • The new and changed tests run offline, with no model, network or cluster.
  • uv run devops ci passes.

Key questions

Activity

  1. added
    type/refactor
    scope/cli
    priority/p3-low
    on Oct 2, 2026
  2. added
    status/ready
    value/low
    effort/high
    on Oct 28, 2026
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned. The item conflicts with a more recent project direction. No code was written.

    This item is a bulk move of help and message text out of lang/en/ into each command module, held by an AST test that fails when a devops_cli.lang attribute has one consumer or when a help= is a literal. Its own key question says it must land "in a window with few open PRs, because it touches about 1,500 help sites and every open command PR would have to rebase".

    The owner decision of 2026-10-22 on #1016 rules out both parts of that mechanism:

    • "No constant moves in this pull request. A constant moves when its module is next touched."
    • "No gate checks the placement. The project adds no new ratchet."

    On 2026-10-28 the same decision closed #1025 to #1032, the bulk moves of single-owner tables out of config/, as not planned, for the same reason. #1016 itself names this item as "the same rule applied to lang/".

    Measured on origin/main d156ce7 (2026-10-28):

    • 1,385 help=HELP. sites and 371 help=" literals under src/. lang/en/help.py has 43 dataclasses in 1,780 lines, and lang/en/messages.py has 2,157 lines.
    • HELP. is read in 60 modules and MESSAGES. in 94.
    • 62 commits on main since 2026-10-21 changed lang/en/help.py or lang/en/messages.py, so a bulk move conflicts with most command work.

    The current documents still send user-facing strings to lang/en/ (docs/ROUTINE_TASKS.md rows 28 and 90). If a person wants help text beside its command, the form that agrees with the #1016 decision is a rule change in CONTRIBUTING.md and docs/ROUTINE_TASKS.md: a string moves to its command when that command is next touched, with no gate. That is a person's decision, so this item builds no part of it.

  4. removed
    status/ready
    on Oct 30, 2026
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/highpriority/p3-lowscope/clitype/refactorvalue/low

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions