Skip to content

fix!: reject positional arguments on a command without an args schema - #21

Merged
robingenz merged 1 commit into
mainfrom
fix/unexpected-arguments
Nov 14, 2026
Merged

robingenz merged 1 commit into
mainfrom
fix/unexpected-arguments

Conversation

@robingenz

Copy link
Copy Markdown
Member

A command without an args schema passed stray positional arguments to its action as a raw string[], without validation. A line such as my-cli login alice ran login, and nothing said that alice was ignored.

Now such a command takes no positional arguments. processConfig throws a ZodlineError that names the first one:

my-cli login alice
# Unexpected argument: alice

This is the rule unknown options already follow: a command without an options schema rejects every flag.

  • processCommandExecution rejects the first positional argument when the command declares no args.
  • A command that reads positional arguments declares a schema. z.array(z.string()) takes them as before.
  • The type of args was already undefined without a schema, so the runtime now matches the type.
  • One new test for the error. Three tests of multi-word commands now declare the schema they relied on.
  • The arguments guide, the commands guide, the error handling guide, the API reference, the README and CLAUDE.md state the rule.

Breaking: a command that reads args without a schema must declare one. BREAKING.md has the section for 0.4.0.

This goes together with #19. There a boolean flag takes no value, so a word after it is positional. On a command without args that word is now an error and no longer dropped. The branch merges cleanly with #19 and #20, and the tests of all three pass together.

🤖 Generated with Claude Code

A command without an args schema passed stray positional arguments to its action without validation. It now throws a ZodlineError that names the first one. A command that reads positional arguments declares an args schema.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Deploy preview available at: https://39067975.zodline-page.pages.dev.

Built with commit 8b05984.

@robingenz
robingenz merged commit fe3e637 into main Nov 14, 2026
5 checks passed
@robingenz
robingenz deleted the fix/unexpected-arguments branch November 14, 2026 08:31
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.

1 participant