Added post processing checking of sub command mandatory flag#127
Added post processing checking of sub command mandatory flag#127eiriktsarpalis merged 5 commits intofsprojects:masterfrom chestercodes:master
Conversation
src/Argu/Parsers/Common.fs
Outdated
| | Choice1Of2 ts, ts' when caseInfo.GatherAllSources.Value -> Array.append ts ts' | ||
| | _, ts' -> ts' | ||
|
|
||
| let rec searchSub caseInfo = |
There was a problem hiding this comment.
I'm sure this could be done in a less allocatey way, since you're only really looking for the first element
There was a problem hiding this comment.
Is that better? the tests pass. Is the wilcard return empty array the right call on line 78?
I'm not 100% sure I understand why unionArg.Cases.Value is a single item array. Is it because any duplicates will have been filtered out by the time this runs?
There was a problem hiding this comment.
Since the only searchSub callsite only checks for the first array element, it should really just return an optional.
There was a problem hiding this comment.
changed it to an option
|
Apologies, this PR seems to have slipped through the cracks. I've rebased your changes on top of the latest master. |
|
Thank you! |
|
Can we get a release pushed with this patch in please? |
|
The more I test this the more I think this does not work properly at all. The actual parsed result is never checked rather it is only looked at the unioncase definition which doesn't make any sense to me because that means that even when a value is provided this will fail. Also it can currently only work for single case unions as a result it does not fix #116 .
@eiriktsarpalis is there an easy way to get the parsed value ({Argu.UnionArgInfo.UnionParseResults}) during the post processing stage to enable checking if it was provided? During debugging it seems to be possible but at design-time everything is obj. At runtime the objects seem deeply nested which would require a lot of dynamic casting to get to the actual value. |
|
As @Angr1st has indicated, this code does not work as expected. I got the following results:
argv: [|"--mandatory-arg"; "true"; "tag"; "--new"|]
ERROR: missing parameter '--name'.
USAGE: gadget tag --new [--help] --name <string>
OPTIONS:
--name <string> New name
--verbose, -v be verbose.
--data <int> <base64> pass raw data in base64 format.
--help display this list of options.
argv: [|"--mandatory-arg"; "true"; "tag"; "--new"; "--name"|]
ERROR: argument '--name' must be followed by <string>.
USAGE: gadget tag --new [--help] --name <string>
OPTIONS:
--name <string> New name
--verbose, -v be verbose.
--data <int> <base64> pass raw data in base64 format.
--help display this list of options.
argv: [|"--mandatory-arg"; "true"; "tag"; "--new"; "--name"; "myName"|]
ERROR: missing parameter '--name'.
USAGE: gadget tag --new [--help] --name <string>
OPTIONS:
--name <string> New name
--verbose, -v be verbose.
--data <int> <base64> pass raw data in base64 format.
--help display this list of options.I've spent some time looking through the code but can't work out how to fix it. |
I think that this fixes - #116 ?
I'm new to the project (and fairly new to F#) so I appreciate I might have missed something in the implementation.