Open
Conversation
Now extra args are treated as separate but merged to call the function. Extra testing is needing to try them in conjunction with other tests. Every function receives the same extra args
Remove increase in x index count when iterating args sin mage file.
Contributor
Author
|
Ok @natefinch this works now as I intended, let me know if this is something we want to support. |
Member
|
I think we need a test where we run mage.ParseAndRun() and pass in a raw args list and see that it does the right thing. Right now, the code in mage/main.go in the Parse function is never tested, and that's pretty key. |
Contributor
Author
|
@natefinch done, added the same test cases, which i consider to be relevant but also using |
Contributor
Author
|
@natefinch I completely forgot this never got merged :p I think the idea is still valid and might be a good way to implement optional args (adding special cases of the base types) |
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.
Proposal
So, this is an idea mostly, i have not been able to test this as running
magejust gets themgfrom upstream, perhaps i should not use upstream?The idea is to support this:
where ideally extra would become a string slice
[]string{"-baz", "blah"}after callingmage targetone foo bar -- -baz blahImplementation
I manged to implement this by having the ExtraArgs be handled out of band with the actual Args, they are accounted by mage and the underlying generated mage file and both handle them correctly.
Ideally users of this will use this as sampled in the various targets in the tests (which is to say, in any way they want) and they will always receive the list of arguments.
The caller should then be the one in charge of processing these, we do no processing whatsoever except removing the leading
--if the user's code implements a flag parser they can passExtraArgsas is and get it parsed. If they want to just give this to a sub-process they can append to the arg list adding again--.This does not solve the issue of people wanting to pass arbitrary arguments to targets, but solves the way to at least being able to pass some form of arbitrary arguments (useful,again, for invoking sub-processes that take external modifyers by commandline)
Note: every target implementing
ExtraArgswill receive the same copy of the slice, it is their responsibility to process them.