Skip to content

Number of Params Actually Passed In #2078

Answered by remkop
irinaleo asked this question in Q&A
Discussion options

You must be logged in to vote

You may be able to get a ParseResult instance like this:

class MyClass {

  @Spec CommandSpec spec;

 @Command(name = "subcommand", description = "Subcommand")
 public void subcommand(
        @Parameters(arity = "1", description = "Parameter 1") String parameter1,
        @Parameters(arity = "0..1", description = "Optional parameter 2") String parameter2,
        @Parameters(arity = "0..1", description = "Optional parameter 3") String parameter3,
        @Parameters(arity = "0..1", description = "Optional parameter 4") String parameter4) {

        ParseResult pr = spec.subcommands().get("subcommand").getParseResult();
        int parameterCount  = pr.expandedArgs().size();

         if (p…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@irinaleo
Comment options

@remkop
Comment options

Answer selected by irinaleo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants