support variadic target arguments - #557
Open
younggglcy wants to merge 3 commits into
Open
Conversation
younggglcy
marked this pull request as ready for review
August 12, 2026 04:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #340.
What this changes
Mage now discovers exported targets whose final parameter is
...stringandpasses the remaining command-line tokens to it unchanged. A variadic target is
terminal for the invocation, so existing fixed-arity target chaining keeps its
current behavior and Mage does not need to guess boundaries from target names.
Pointer-style optional arguments may precede the variadic tail. In that form,
Mage parses flags until the first non-option token; a target-local
--can beused when the tail itself starts with
-. This separator is intentionallyscoped to optional-plus-variadic targets: pure variadic targets still receive
--literally, and non-variadic target behavior is unchanged.The parser metadata is shared by generated dispatch and help output, and the
website documentation describes the same terminal-target and pass-through
semantics. Unsupported non-string variadics remain hidden. Alias conflicts are
reported only when this feature makes a variadic target newly discoverable, so
historical fixed-arity alias behavior is preserved.
Example
mage run worker -verbose -- -race ./...Validation
go test -vet=all -tags CI -race ./...go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.2 run