Skip to content

docs: clarify that named Arguments are excluded from cmd.Args() - #2411

Merged
dearchap merged 1 commit into
urfave:mainfrom
dearchap:issue_2387
Aug 16, 2026
Merged

docs: clarify that named Arguments are excluded from cmd.Args()#2411
dearchap merged 1 commit into
urfave:mainfrom
dearchap:issue_2387

Conversation

@dearchap

Copy link
Copy Markdown
Contributor

What this does

Closes #2387.

Issue #2387 reported that positional arguments consumed by named Arguments (e.g. &cli.StringArg{Name: "test"}) don't show up in cmd.Args(). This is intended behavior that dates back to the original arguments feature (#1074): each named argument consumes the positional arguments it needs, and cmd.Args() returns only the unconsumed (leftover) arguments. The consumed values are retrievable via cmd.{Type}Arg(name) (e.g. cmd.StringArg("test")).

This PR documents that behavior so it isn't a surprise:

  • Clarify the Command.Args() doc comment (and regenerate godoc-current.txt / testdata/godoc-v3.x.txt).
  • Add a "Mixing named arguments with cmd.Args()" section to docs/v3/examples/arguments/advanced.md with a runnable example and the trailing StringArgs{Max: -1} glob pattern.
  • Add a note to docs/v3/examples/arguments/basics.md pointing to the advanced docs.
  • Add TestArgsConsumedByNamedArguments to lock in the documented semantics.

Verification

  • go test ./...
  • go vet ./...
  • make lint (goimports)
  • make generate && make v3approve && make v3diff
  • make gfmrun FLAGS='--walk docs/v3/' (error_count=0)
  • mkdocs build succeeds

@dearchap
dearchap requested a review from a team as a code owner August 16, 2026 15:11
@dearchap
dearchap merged commit d04da99 into urfave:main Aug 16, 2026
7 checks passed
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.

Named arguments don't get passed in cmd.Args()

1 participant