Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse original input command line was not supportted #15

Open
justbeay opened this issue Oct 25, 2017 · 2 comments
Open

parse original input command line was not supportted #15

justbeay opened this issue Oct 25, 2017 · 2 comments

Comments

@justbeay
Copy link

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

@ghost
Copy link

ghost commented May 2, 2018

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.

@spullara
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants