jontejj / jargo

Argument and options parser for java
Other
1 stars 1 forks source link

variableArity does not end when new argument appears #26

Open tomasbjerre opened 5 years ago

tomasbjerre commented 5 years ago

I'm using variable artity:

    final Argument<List<List<String>>> violationsArg =
        stringArgument("--violations", "-v")
            .variableArity()
            .repeated()
            .description(
                "The violations to look for. <PARSER> <FOLDER> <REGEXP PATTERN> <NAME> where PARSER is one of: "
                    + parsersString
                    + "\n Example: -v \"JSHINT\" \".\" \".*/jshint.xml$\" \"JSHint\"")
            .build();

This works great:

npx violations-command-line -s ERROR -mv 0 \
 -v "CHECKSTYLE" "." ".*checkstyle/main\.xml$" "Checkstyle" \
 -v "JSHINT" "." ".*jshint/report\.xml$" "JSHint"

But if I move single parameter arguments after arguments with variable arity:

npx violations-command-line \
 -v "CHECKSTYLE" "." ".*checkstyle/main\.xml$" "Checkstyle" \
 -v "JSHINT" "." ".*jshint/report\.xml$" "JSHint" \
 -s ERROR -mv 0

The -s ERROR -mv 0 is parsed as arguments to -v.

Is this intended? What I would have wanted is to have same result as in first example.

https://github.com/tomasbjerre/violations-command-line/blob/master/src/main/java/se/bjurr/violations/main/Runner.java

jontejj commented 5 years ago

It's kind of intended as it wouldn't be possible to pass "-s" as a string argument to -v otherwise?

jontejj commented 5 years ago

Maybe there could be an opt-in on the variable arity parser though?

Something like:

.variableArity().preferOtherArgsIfMatched().repeated()...
tomasbjerre commented 5 years ago

Sounds great!

Off topic: I think you can contact GitHub to have the fork reversed, make this repo main repo. And perhaps event move issues. Or I can do ask tell them to do it, as I am a member of @Softhouse on Github?

jontejj commented 5 years ago

That would be awesome!

tomasbjerre commented 5 years ago

This is now the main repo :)

jontejj commented 5 years ago

Thanks!