-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Command parameters are not parsed entirely as I would expect and I do not see anything in the documentation to point me to a solution at this point.
Comments in the source of ManyConsole suggest that the behavior for parsing parameters should be as such:
// this command
my-command --integer 1 --string "some long text value" --collection param1 param2 param3
// should evaluate to
--integer == 1
--string == "some long text value"
--collection = ["param1", "param2", "param3"]
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx
Instead, the option --string ignores any quote and parses the space delimiter.
// actual parameterization
--string == "some
--collection == param1
// then everything else falls into a generic container:
AdditionalArguments == long, text, value", param2, param3
How can several values be collected in one parameter call?
// In the derived ConsoleCommand constructor I want to avoid something like:
my-command --string some --string long --string text --string value
// and then doing:
HasOption<string>("s|string=", v => StringList.Add(v));
// finally:
var stringValue = string.Join(" ", StringList);
I could parse out the remaining arguments after all single value command options are captured, but it will be difficult to come up with a constant number of parameters for the "HasAdditionalArguments" override.
Here's a sample of what I'm doing:
public class TestCommand : ConsoleCommand {
public TestCommand() {
IsCommand("my-command");
StringList = new List<string>();
HasOption("s|string=", "captures a text parameter", s => StringList.Add(s));
}
public List<string> StringList;
public override int Run(string[] remainingArguments) {
var stringValue = string.Join(" ", StringList);
System.Console.WriteLine("Received input: " + stringValue);
return 0;
}
}
Let me know if I'm missing any existing configuration here. Perhaps I can override the argument delimiter per option?