Skip to content

fix(cli): refuse an option a command does not take, and honour --help after a command - #301

Merged
goldbarth merged 1 commit into
mainfrom
fix/strict-arguments
Sep 30, 2026
Merged

goldbarth merged 1 commit into
mainfrom
fix/strict-arguments

Conversation

@goldbarth

Copy link
Copy Markdown
Owner

Closes #300

  • Why: the CLI checked only the first word. Every option after it was looked up by name and anything unknown passed over, so generate --help started a run that, with a token that may publish, made every model call and created a draft; --nopublish published; --tga and a --tag without a value ran for the nearest tag; --tag --audience technical named a tag --audience.
  • Checked before anything starts, not read leniently: CommandLineArguments.Check runs in Program before configuration, git or GitHub, and refuses a command line it cannot read as meant, the rule the configuration file already follows (An empty list in chartula.yaml is read as no setting, so excludeCategories: [] keeps [Internal] #277, chartula.yml is ignored without a word when chartula.yaml exists next to it #278). The readers (GetOption, HasFlag, GetOptions) stay as they are: after the check they only see well-formed arguments.
  • Each command has its own options: preview and generate take --tag, --repo, --since, --audience and --yes; only generate takes --no-publish; doctor takes --tag and --repo. An option of another command says whose it is (--no-publish is an option of generate, not of preview.).
  • An unknown option suggests the closest one within two edits (Did you mean --no-publish?), so the message carries the fix.
  • A value option needs a value that is not itself an option, so --tag --no-publish stops instead of naming a tag. A single-value option given twice stops rather than the first winning; --audience stays repeatable, as documented.
  • -h and --help win wherever they stand, after the command is known and before anything is checked, and exit 0. help stays a first-word command only, since a later help is more likely a value than a request.
  • Two forms get their own message: --tag=v1.2.0 says to write it with a space, and --whole-history, removed in feat: render a first tag from the first commit, and confirm a large range before it is read #282, says what replaced it. feat: render a first tag from the first commit, and confirm a large range before it is read #282 had relied on unknown options being ignored for it.
  • Errors go to stderr with one line pointing to chartula --help, exit 1, the same as the other usage errors. The help text says which options doctor and generate alone take.
  • docs/cli.md: the copied help text matches chartula --help line for line again, and the page states that options are checked, with the --nopublish example.

Reproduced and verified end to end with the built binary in a scratch clone, GitHub pointed at a local stub that logs every request and the model at a closed port:

                                   main                                  this branch
generate --help                    run starts, reaches the publish check help, exit 0, no request
generate --nopublish               run starts, reaches the publish check Did you mean --no-publish?, exit 1
preview --tga v0.1.0-preview.2     runs for v0.1.0-preview.3             Did you mean --tag?, exit 1
preview --tag                      runs for v0.1.0-preview.3             --tag needs a value, exit 1
preview --tag --audience technical Tag '--audience' is not in the checkout --tag needs a value, exit 1

Also refused, with no request: a repeated --tag, --no-publish on preview, --since on doctor, --whole-history, --tag=..., a bare v0.1.0-preview.2. preview --audience technical --audience customer --tag ... still runs. Every CLI call in the docs, the workflows and the install checks still passes the check.

Tests: CommandLineArgumentsTests (every option of each command passes; each refusal with its exact message; --whole-history; which flags ask for help), ArgumentCheckTests through the built CLI (generate --help, generate --tag v1.0.0 -h and doctor --help print the help and start nothing; --nopublish stops before the checkout is read). Full suite passing, build without warnings, dotnet format clean.

@goldbarth
goldbarth merged commit bbcd666 into main Sep 30, 2026
4 checks passed
@goldbarth
goldbarth deleted the fix/strict-arguments branch September 30, 2026 15:58
goldbarth added a commit that referenced this pull request Sep 30, 2026
… exit status (#302)

Follows #299, which took the failure messages out of `cli.md` into
`troubleshooting.md`, and #301, which made the CLI refuse an option it
cannot read as meant.

- **Why:** `cli.md` mixed reference with setup and concepts: a copied
help text, a first-run style tour, the model failure messages, and the
range rules. It becomes the reference only, so a reader finds every
command, option, default, variable, stream and exit status in one place,
and the rest where it lives.
- **The copied help text is gone.** The page points to `chartula
--help`, which prints from the binary and so always matches the
installed version. In its place, one table of the commands (model calls,
files, publishing) and one table of every option with its value, default
and the commands that read it.
- **How options are checked, as #301 made it:** options follow the
command in any order, `--audience` may repeat, every other option comes
once; `-h` and `--help` print the help after a command too. The page
shows the `--nopublish` message and a table of the other refusals (an
option of another command, a missing value, an option given twice, `=`
instead of a space, a word that is no option), each with the message the
built binary printed.
- **`--tag` and `--repo` keep their defaults with their messages;**
`--since`, `--yes`, `--audience` and `--no-publish` each keep a short
section with the message a wrong value gives. The explanation of the
range stays in `what-goes-into-a-release.md`.
- **New: what goes to stdout and what to stderr,** from `Program.cs`,
`ReleaseCommand.cs` and the composition root, including that the range
question needs stdin to be a terminal and the progress line updates in
place only when stderr is one.
- **Exit status as a table** of every case that gives 0 and 1.
- **Environment:** the three credential variables with a link to their
home each; `Chartula__` settings and the environment-only settings link
to `configuration.md`; the install script variables link to
`install.md`.
- **`doctor`, `--version` and `preview` as the free command it is
(#292),** and what a run prints while it works (#297), stay; the
first-run walkthrough stays in `getting-started.md`.
- **Kept for 3.1:** the list of outputs under `generate` stays until
`docs/outputs.md` takes it.
- `providers.md`: one link pointed to the removed
`#when-a-model-call-fails`; it points to
`troubleshooting.md#a-model-call-fails`. README: the index row describes
the page as it is.

**Verified:**
- Every command, option and message on the page was run with the binary
from `main` against a scratch repository and local GitHub and model
stubs, with stdout and stderr captured apart: `--help`, no arguments,
`help`, `--version`, an unknown command, an unknown option, `--tag`
without a value, an unknown audience, `--since` without a value and with
a ref that is no commit, an invalid `--repo`, `preview` with and without
`--audience` and `--no-publish`, `generate` with and without
`--no-publish`, `doctor` with and without `--tag`, and `generate
--help`, and after #301 every refusal in the page's table
(`--nopublish`, `--tga`, `--tag` at the end and before `--no-publish`,
`--no-publish` on `preview`, `--since` on `doctor`, `--tag` twice,
`--tag=v1.3.0`, a bare `v1.3.0`). The exit status of each matches the
table.
- The `preview` example is a real run on this repository's
`v0.1.0-preview.3`; the `--version` line is the build of `main`.
- Every relative link and anchor in all Markdown files of the repository
resolves (script, with a negative test).
- No code, comment or message changed.

Tests: none, documentation only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No


---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <[email protected]>
goldbarth added a commit that referenced this pull request Sep 30, 2026
…its issue (#303)

Follows #299 and #301; after them every issue the documentation plan
waited for is closed.

- **Why:** `ROADMAP.md` described plans in internal terms ("pull request
text as data", "an author-supplied outcome as a fact source"), linked
only three of its points, still listed the launch work as it stood
before `doctor`, `--version` and the thorough-check measurement landed,
and did not say which point removes which known limitation. A reader
could not tell what a point changes for them, whether work on it exists,
or when a limitation goes away.
- **One bold sentence per point on what changes for the user,** then at
most one sentence of detail. The internal wording is gone.
- **Every point links its issue or milestone, or says "No issue yet".**
The issue list was checked in full: only the GitHub Action (milestone
6), native AOT (milestone 8) and #249 have one; the rest have none, and
the page says so rather than implying work in progress.
- **"Now" names the actual launch scope:** the three open issues of the
Launch milestone (#210, #211, #226), each as what it changes, and this
documentation rework, which has no issue. `chartula doctor`, `--version`
and the thorough check's measured default (#176) are shipped and leave
the list; `doctor` joins the sentence on what the alpha has.
- **#249 joins point 2,** which it is: a run with flags stops before it
writes, and a published release is not changed unasked. The working-tree
protection in the same point has no issue and says so.
- **GitLab joins as point 9,** last, since the order after it was not
decided; the README's "GitHub is the only source" is the limitation it
removes.
- **Plans and limitations each live in one place:** the README keeps the
limitations, the roadmap names each one it removes with the README's
exact wording (checked by script: all eight names match a README
bullet), and the README's introduction to the limitations points to the
roadmap for the order instead of saying "after the alpha".
- **Point 5 is worded from stored facts, not from `changelog.json`:**
since #294 the facts with their descriptions are in the run record, and
`changelog.json` no longer carries what rendering needs. Point 8 no
longer promises a runtime-free binary, because the binaries are already
self-contained (`docs/install.md`); it says what native AOT changes, a
native executable that starts faster.

**Verified:**
- Every issue and milestone link was checked against the GitHub API, and
the open issues of each milestone against the points that name them.
- Every relative link and anchor in all Markdown files of the repository
resolves (script, with a negative test).

Tests: none, documentation only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No

---
_Generated by [Claude
Code](https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No)_

Co-authored-by: Claude <[email protected]>
goldbarth added a commit that referenced this pull request Oct 1, 2026
…320)

Follows #319 (ADR 0004); this branch builds on it for the index row and
is rebased onto `main` once #319 is merged.

- **Why:** seven changes since September made Chartula stop where it
used to choose silently, each with its own reasoning in its pull
request, but the rule they share was written down nowhere. A contributor
adding an option or a setting could not tell whether to refuse an
ambiguous value or take the likelier reading, nor when refusing goes too
far.
- **Context** lists the seven cases in one table, each with what the
silent choice did and the change that ended it: a first tag (#198 for
#138, #282), a key sent to the other provider's host (#235), an unknown
or misindented key (#238), a shallow clone read as a first release
(#244), review mode approving unseen text (#247), two configuration
files (#287 for #278), and options a command does not take (#301).
Decided is #198, the first of them.
- **Decision:** stop and say so instead of choosing; before anything is
spent; with a message that names the cause and the fix, shown with two
real messages; ask at a terminal where the answer is the user's, and
stop naming the option without one; refuse only what Chartula can tell
for certain (an empty list, an unknown host and an unknown model id are
taken as written); refuse a setting that would have no effect. The rule
is about what the user meant, not about what the release says, which is
what flags are for.
- **Consequences** name the cost: a run that could have produced
something stops, and a CI job fails until the input says what it means.
The ADR weighs that rerun against what a silent choice cost in the seven
cases. For a new case, four questions in order, so a contributor can
apply the rule rather than match it against the examples.
- The index in `adr/README.md` lists 0005.

**Verified:**
- Each case was checked against its pull request's description and the
issue it closes (#237, #243, #233, #278, #300, #138); the dates are the
merge dates.
- Both messages are the ones `docs/cli.md` and `docs/configuration.md`
show from the built binary.
- The counter-cases were checked in the code: `ProviderHost` accepts
every host but two, `ClaudeThinkingSupport` passes an unknown model id,
#289 reads an empty list as written, and #244 still runs `--since` in a
shallow clone when the range holds.
- Every relative link and anchor in all Markdown files of the repository
resolves (script, with a negative test).

Tests: none, documentation only.
goldbarth added a commit that referenced this pull request Oct 1, 2026
…ape the template like the merged ones (#322)

Follows #316 and #318, after which CONTRIBUTING can link the testing
page and the ADR index instead of explaining either.

- **Why:** CONTRIBUTING told a contributor to clone `goldbarth/chartula`
as "your fork", had no word on branches, review or how a merge closes an
issue, did not say that a pull request's title and description become
Chartula's own release notes, listed types without saying which ones
reach a release, and asked for a PR description ("what and why") unlike
any that has been merged. The template asked for a type checkbox and a
checklist none of the merged pull requests fill in.
- **From a fork to a merged pull request** in six steps: fork and
`upstream`, a branch named after type and topic (as the 40 last merged
branches are), commit, open, review, merge. The merge step says what the
repository is set to do: squash, with the PR title as the commit title
and the description as the message, so `Closes #123` in the description
closes the issue and stays in the history.
- **"Your pull request is Chartula's input":** the title is the line a
release names the change by, its type decides whether it appears, and
the description is what the model reads, so it can reach a published
note. Links `writing-pull-requests.md` instead of repeating it.
- **Setup:** the exact SDK with an install command, and lock files: what
rewrites them, that they are committed with the change, and the locked
restore CI runs, as a command to check before pushing.
- **Build, test and format** as the three commands CI runs, a single
test with `--filter`, and the hook; the rest links `testing.md`.
- **Trying the CLI on a repository:** where the binary is, what
`preview`, `generate --no-publish` and `generate` cost or change, and
the local stub for the model path.
- **Types with a column "In the release notes",** worked out from the
category table and this repository's `chartula.yaml`: `refactor` and
`docs` appear only with `visibility:user-facing`, `test`, `build`, `ci`,
`chore` and `style` are dropped as internal, `revert` appears unless its
target is in the same release. Scopes are the folders, as before.
- **The pull request** describes the shape the merged ones share (the
`Closes` or `Follows` line, a bullet per decision with its reason, a
bold verification section, a `Tests:` line) with a shortened #301 as the
example, and keeps the short list of checks before opening.
- **Writing documentation** gives the rules the pages follow, from the
documentation plan, so a docs contribution needs no other source.
- **The template** has the same four parts with comments that say what
goes in each, and drops the type checkboxes and the checklist.

**Verified:**
- The merge settings from the repository API
(`squash_merge_commit_title: PR_TITLE`, `squash_merge_commit_message:
PR_BODY`), and that the last 20 commits on `main` are squash merges.
- The CI commands against `.github/workflows/ci.yml`; `dotnet restore
Chartula.slnx --locked-mode` passes on this branch.
- The type column against `what-goes-into-a-release.md` (categories,
what is dropped, who can meet a change, reverts) and
`GroundedFactsFactory.Reaches`.
- The example against #301's description; branch names against the head
branches of the last 40 merged pull requests.
- Every relative link and anchor in all Markdown files of the repository
resolves (script, with a negative test).

Tests: none, documentation only.
goldbarth added a commit that referenced this pull request Oct 7, 2026
Follows #344. Step 1 of `docs/development/releasing.md`.

- **Why now:** the launch points are merged, and the binary people
install is still `0.1.0-preview.3`, which has none of them. The
announcement needs a release that holds what the README and the docs on
`main` describe.
- **What ships since preview.3,** 63 commits:
- a first run: `chartula doctor` (#295, grouped in #341), `chartula
--version` (#286), a free `preview` (#292), progress while a run works
(#297, with a spinner and `--plain` in #340), a first tag from the first
commit with a confirmation for a large range (#282);
- what a release contains: commits without a pull request (#291), issue
numbers at every depth (#293), a sentence for a release with nothing for
developers (#307 in #333);
- checks and prompts: pull request text quoted and bounded (#338), no
false flag for a wrapped phrase or a fenced block (#336), flags set
apart from the entries (#331);
- publishing: the token checked before the first model call (#285), a
published release not replaced unless asked (#335);
- the files: `changelog.json` without descriptions and readable as text
(#294, #332).
- **Breaks to state in the notes,** as `docs/versioning.md` asks of a
preview:
- `changelog.json` is schema version 2: a change's `description` is gone
(#294). The run record is schema version 3 and holds the complete facts.
- `generate` stops on a tag whose release is already published;
`--replace-published` restores the old behaviour (#335).
- An option a command does not take stops the run (#301), and
`--whole-history` is gone (#282).
- The terminal output changed form (#340 to #342): the summary's first
line, audience headings in place of `--- Technical ---`, and `doctor`'s
last line. A script that reads those lines needs a look; exit codes and
the files are unchanged.
- The csproj `Version` is the single source; nothing else carries the
number.

**After merge:** tag the merge commit on `main` with `v0.1.0-preview.4`
and push it; `release.yml` builds the draft, `chartula generate --tag
v0.1.0-preview.4` writes the notes into it, and publishing runs
`install.yml`. The pinned `v0.1.0-preview.3` in `docs/ci.md` and
`docs/install.md`, and the template link in the `doctor` samples, move
to the new tag once the release exists, with the changelog pull request
of step 6.

**Verified:** the built CLI prints `chartula 0.1.0-preview.4+<commit>`.

Tests: no test changed. Full suite 1,010 passing, build without
warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The CLI ignores unknown options, so a typo runs, and generate --help publishes

1 participant