Skip to content

Document argument syntax for optional long options - #145

Open
jadenfix wants to merge 2 commits into
rust-lang:mainfrom
jadenfix:docs/optional-long-argument
Open

jadenfix wants to merge 2 commits into
rust-lang:mainfrom
jadenfix:docs/optional-long-argument

Conversation

@jadenfix

@jadenfix jadenfix commented Oct 18, 2026 •

Copy link
Copy Markdown

The crate-level docs currently say options accept a value after a space or =, but optflagopt intentionally treats --text foo as an option without a value plus a free argument. This can silently surprise callers using the documented syntax.

Distinguish required arguments from optional long-option arguments, document the long/short forms on optflagopt, and extend its runnable example to show --text foo and -t foo. Parser behavior is unchanged.

The public CLI reproducer confirms the distinction on current main. Default and no-default tests, all 12 doctests, documentation with warnings denied, and formatting pass locally on macOS. Other platforms remain upstream CI checks.

The examples also cover a lone - as a short-option value and a following long option retaining its own meaning.

Fixes #104.

Prepared with Codex assistance and independently reviewed by another agent before submission.

This branch has not been deployed

No deployments
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.

Bug in optflagopt

1 participant