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
privatereadonlyArgument<List<string>>inputArg=new("input","Files to process");
I don't get any validation if the list is empty, as with single-token arguments. Right now i'm doing this to check for emptiness and print help to replicate default behavior which is not straightforward too:
privateasyncTask<int>Handle(InvocationContextcontext,CancellationTokentoken){varinput=context.ParseResult.GetValueForArgument(inputArg);if(!input.Any()){varname=GetType().Name.ToLowerInvariant();awaitusingvarsw=newStringWriter();awaitsw.WriteLineAsync($"Required argument missing for command: '{name}'.\n");context.HelpBuilder.Write(this,sw);context.Console.Write(sw.ToString());return0;}// rest of the handler}
Is there a way to specify that collection-type argument should be not empty?
Is there a way to trigger validation failure, simpler than HelpBuilder.Write?
The text was updated successfully, but these errors were encountered:
If i specify an Argument like this:
I don't get any validation if the list is empty, as with single-token arguments. Right now i'm doing this to check for emptiness and print help to replicate default behavior which is not straightforward too:
The text was updated successfully, but these errors were encountered: