Skip to content

Fail generate when --generator has no name, and accept --generator=Name [patch] - #268

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/259-generator-option-without-value
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/259-generator-option-without-value

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #259

What changed

GetOption only recognised --generator when its value came as a separate token. In two cases it returned null, which Generate reads as "no filter":

  • the option was the last argument
  • it was written --generator=Name

Either way, every generator ran and the command exited 0.

Generate now reads the filter through TryGetGeneratorFilter before it loads the schema or writes anything:

  • --generator with no value, followed by another option (--generator --verbose), or written as an empty --generator= → '--generator' needs a code generator name., exit Failure, nothing written.
  • --generator=Name → selects that generator, as the triage comment recommended.
  • An absent option still means every generator, and --generator Name behaves as before.

FindSchemaPath already steps over --generator=Name as a single token, so it needed no change. Rejecting unknown options was optional in the issue and is left out.

Tests

  • TestGeneratorOptionWithoutANameFailsAndWritesNothing (three data rows: --generator, --generator=, --generator --verbose) checks for Failure, the error text, and that no out/ directory is created.
  • TestGeneratorOptionAcceptsTheEqualsForm: --generator=CSharp writes Item.g.cs, and --generator=Cpp fails with "no code generator named 'Cpp'".
  • With the fix reverted, all 4 new cases fail. With it, they pass. The existing --generator tests still pass.
  • dotnet test Schema.Test: 514/514 passing locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_019FkGdWB8Ko3mTn9JiBH973


Generated by Claude Code

…me [patch]

GetOption only recognised `--generator Name` as two tokens. With the option
last, or written `--generator=Name`, it returned null, which Generate reads
as "no filter", so every generator ran and the command exited 0. Read the
filter before loading anything: a bare `--generator`, one followed by
another option, or an empty `--generator=` now fails with
"'--generator' needs a code generator name." and writes nothing, and
`--generator=Name` selects that generator.

Fixes #259

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FkGdWB8Ko3mTn9JiBH973
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 132d915 into main Oct 9, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/259-generator-option-without-value branch October 9, 2026 08:05
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.

kschema generate runs every generator when --generator has no value or is written --generator=Name

2 participants