How to use a space separator without quotes #473
-
I have the folowing class that implements public class MyArgs : IArgumentModel
{
[Option("exclude", Description = "A space-separated list of names ...", Split = ' ')]
public string[]? Exclude { get; set; }
} When I invoked it I had to invoke it with quotes e.g. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You've run into a limitation between terminals/consoles/shells and the programs they run. The shell will have already split the line on spaces so it can map the command to the program you've developed. The If you really want to try to work around this, you can get access to the original string from Environment.CommandLine but you'll need to parse the entire line yourself. It's not as trivial as you'd initially think. Alternatively, do not rely on spaces. Using |
Beta Was this translation helpful? Give feedback.
You've run into a limitation between terminals/consoles/shells and the programs they run. The shell will have already split the line on spaces so it can map the command to the program you've developed. The
args
inMain(string[] args)
is what was already split. Given space is the default argument delimiter, the shell (and even the CommandDotNet framework) does not have enough context to understand when a user would not want that behavior. Since this is already split before the program is invoked, you'll have this problem with any framework.If you really want to try to work around this, you can get access to the original string from Environment.CommandLine but you'll need to parse the enti…