cli-parser icon indicating copy to clipboard operation
cli-parser copied to clipboard

parse original input command line was not supportted

Open justbeay opened this issue 7 years ago • 2 comments

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...

justbeay avatar Oct 25 '17 03:10 justbeay

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.

ghost avatar May 02 '18 21:05 ghost

That wouldn't work with quoted sections in the command line. I never saw what motivated this additional api though?

spullara avatar May 30 '24 22:05 spullara