Skip to content

Filter subcommands at runtime when declared with annotations. #1256

@MarkoMackic

Description

@MarkoMackic

Hi, is there currently a way to filter subcommands at runtime if they are declared with annotations ?

@Command(name="xx", subcommands={YY.class, CC.class, AA.class})
class XX implements Callable<Integer>
{
   
    // this is API example of my implementation, though I don't really like it, it's not strongly typed, but it should be something in this form.
 
    public static Boolean picocliFilterSubcommand(Class subcommand)
    {
          if(Boolean.valueOf(System.getProperty("DISABLE_CC_SUBCOMMAND"))
             return subcommand == CC.class;
    }
   
    @Override
    public Integer call() throws Exception
    {
    }
}

Here is that PR in my fork implementing this, but I think there should be a way to more properly implement this

MarkoMackic#1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions