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

Recognition of Aliases for Subcommands #443

Closed
kalexmills opened this issue Aug 14, 2018 · 6 comments
Closed

Recognition of Aliases for Subcommands #443

kalexmills opened this issue Aug 14, 2018 · 6 comments
Labels
theme: parser An issue or change related to the parser type: bug 🐛
Milestone

Comments

@kalexmills
Copy link
Contributor

kalexmills commented Aug 14, 2018

The below mixture of 1 parent command with 1 sub-command with aliases fails to recognize subcommand aliases properly.

INPUT: cb t

Expected output:

Running Collabbook main command!
Create task

Actual output:

Unmatched argument: t
Usage: cb [-hV] [COMMAND]
Collaborate on tasks in your git repo from the terminal.
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.
Commands:
  task  Create task
  note  Create note

MWE

@Command(description="Collaborate on tasks in your git repo from the terminal.",
         name="cb", mixinStandardHelpOptions = true, version="")
public class Collabbook implements Callable<Void>  {

    public static void main(String[] args) {
        CommandLine cmd = new CommandLine(new Collabbook())
                .addSubcommand("task", new CreateTask());

        List<Object> result = cmd.parseWithHandler(new RunAll(), args);
    }


    @Override
    public Void call() throws Exception {
        System.out.println("Running Collabbook main command!");
        return null;
    }
}

@Command(description="Create task", name="task", aliases={"t"})
public class CreateTask implements Callable<Void> {

    @Override
    public Void call() {
        System.out.println("Create task");
        return null;
    }
}

@remkop
Copy link
Owner

remkop commented Aug 14, 2018

Thanks for the bug report! I've been able to reproduce this problem. Looking into it.

@remkop remkop added this to the 3.5.2 milestone Aug 14, 2018
@remkop remkop closed this as completed in 3d00695 Aug 14, 2018
@remkop
Copy link
Owner

remkop commented Aug 14, 2018

Fixed in master.

@remkop
Copy link
Owner

remkop commented Aug 14, 2018

I released picocli 3.5.2 that includes the fix for this issue. Enjoy!

@kalexmills
Copy link
Contributor Author

Confirmed this works in 3.5.2

@remkop Thank you for being awesome.

@remkop
Copy link
Owner

remkop commented Aug 14, 2018

😇
No worries.
Glad you like it!

@remkop
Copy link
Owner

remkop commented Aug 14, 2018

Thanks again for the bug report!

@remkop remkop added the theme: parser An issue or change related to the parser label Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: parser An issue or change related to the parser type: bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants