question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recognition of Aliases for Subcommands

See original GitHub issue

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;
    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
remkopcommented, Aug 14, 2018

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

0reactions
remkopcommented, Aug 14, 2018

Thanks again for the bug report!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bash Subcommand Aliases - eklitzke.org
A number of UNIX CLI tools use the "subcommand" pattern, meaning the command takes a subcommand argument separated by whitespace.
Read more >
Can I alias a subcommand? (shortening the output of `docker ...
In general, shell aliases have very minimal functionality -- prefix substitution, no room for conditional logic. If you want to do anything fancy...
Read more >
Command substitution in alias resolved in bash profile?
1 Answer 1 ... In order to get it to work with an alias, you need to use single quotes to prevent the...
Read more >
netstat subcommand - IBM
The netstat subcommand symbolically displays the contents of various network-related ... Protocol names and aliases are listed in the /etc/protocols file.
Read more >
An Empirical Investigation of Command-Line Customization
coding methods, we found three types of aliases that each enable ... ing commands, abbreviating subcommands, and bookmarking lo-.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found