You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't particularly an issue so much as point of confusion on my part. I need, effectively, a optional list. Specifying an argument as having type string list option throws an error, and the docs do specify Note that arguments that use optional or list must have precisely one parameter -- so, alright. But if I specify that a parameter has type string list, it's now required. What I'm looking for is, "if the user doesn't specify a list, the list will be empty list", say. Perhaps the correct approach is a default value in the App.config? Would be very curious if there's a "recommended" way to do this.
The text was updated successfully, but these errors were encountered:
You can use the GetResults method which returns a list of all arguments. So if you pass the args
-f 1 -f 2 -f 3
Then GetResults <@ f @> would give back [1 ; 2 ; 3]. Assuming -f works with lists, then you'd be given a list of lists, so concatenating that result should be sufficient to get the desired result.
I ran into a similar issue. let's say I want something like
typeArguments=| Numbers ofnumbers:intlistinterface IArgParserTemplate withmembers.Usage=match s with| Numbers _->"Optional list of numbers to process (e.g. 10042 10043)"
So that I could invoke the app in two ways
app.exe --numbers 10042 10043 or app.exe
The former behaves as expected. However, the later throws Unhandled Exception: Argu.ArguParseException: ERROR: missing argument '--numbers'.
Whereas what one would expect to happen is that the parse would pass with the following behaviour
Sounds reasonable. It's been ages since I wrote that code, but I have a slight hunch that the restriction might have been motivated by technical reasons.
bartelink
changed the title
Question: correct way to specify a list that's allowed to be empty?
feat: correct way to specify a list that's allowed to be empty?
Dec 14, 2023
This isn't particularly an issue so much as point of confusion on my part. I need, effectively, a optional list. Specifying an argument as having type
string list option
throws an error, and the docs do specifyNote that arguments that use optional or list must have precisely one parameter
-- so, alright. But if I specify that a parameter has typestring list
, it's now required. What I'm looking for is, "if the user doesn't specify a list, the list will be empty list", say. Perhaps the correct approach is a default value in theApp.config
? Would be very curious if there's a "recommended" way to do this.The text was updated successfully, but these errors were encountered: