Conversation
There was a problem hiding this comment.
Pull request overview
Adds “optional argument” support to mage targets by treating pointer-typed parameters as optional and parsing them from -name=value flags, with corresponding updates to help/usage output and new test coverage.
Changes:
- Extend
parsemetadata to mark pointer parameters as optional and generate execution code that parses-name=valueoptions into pointer variables. - Update generated help/usage to show required args positionally and optional args in bracketed
[-name=<type>]form. - Add parse- and invocation-level tests plus test magefiles/testdata demonstrating optional arguments across supported types.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| site/content/targets/_index.en.md | Documents optional arguments via pointer params and -name=value CLI syntax. |
| parse/testdata/optargs.go | New parse testdata covering optional args across supported base types. |
| parse/parse_test.go | Adds unit test asserting optional args are detected and typed correctly. |
| parse/parse.go | Adds Arg.Optional and generates optional-arg parsing code + usage helpers (Required/Optional args). |
| magefile.go | Removes previously defined alias/target sample code from repo magefile. |
| mage/testdata/optargs/magefile.go | New runtime test magefile demonstrating optional args and chaining behavior. |
| mage/template.go | Updates help output and required-arg counting to account for optional args. |
| mage/args_test.go | Adds end-to-end tests for optional args parsing, errors, chaining, and help output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
This update adds support for optional arguments, which are indicated in the go code by pointer arguments. In the CLI, you must use
-arg=valuesemantics to specify optional values (or just -arg if the argument is a boolean and you want to specify true).