cli-parser
cli-parser copied to clipboard
parse original input command line was not supportted
com.sampullara.cli.Args.parse() only support args split into array already, hope that one override method like: com.sampullara.cli.Args.parse(Object target, String commandLine) would be added someday...
It's actually quite simple to split the args yourself. Assuming commandLine
is a string containing all the command line arguments, you can pass to Args.parse()
like this:
Args.parse(target, commandLine.split(" "));
As you can see, we just split()
the string every time there is a space, and this method will return an array. Otherwise, it would be incredibly simple to implement this method in the Args
class:
public static List<String> parse(Object target, String commandLine) {
return parse(target, commandLine.split(" "), true);
}
Which would do exactly what you asked.
That wouldn't work with quoted sections in the command line. I never saw what motivated this additional api though?