Skip to content

Adding sub command description on generated usage help #333

@ghost

Description

The generated help with included subcommands, does not show how to apply the subcommand.

For example:

public class DemoApp {

    @Command(name = "demo", subcommands = DemoCmd.class)
    static class Demo implements Runnable {

        @Option(names = {"-h", "--help"}, usageHelp = true)
        private boolean help;

        public void run() {
            System.out.println("Print help message.");
        }
    }

    @Command(name = "cmd")
    static class DemoCmd implements Runnable {

        @ParentCommand
        private Demo parent;

        @Override
        public void run() {
            System.out.println("DONE");
        }
    }

    public static void main(String[] args) {
        CommandLine.run(new Demo(), System.out, "-h");
    }
}

prints to the console:

Usage: demo [-h]
  -h, --help
Commands:
  cmd

The user may be asking how to apply the subcommand since it is only showing demo [-h].

Could be possible to show for example:

Usage: demo [-h] [command]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions