Skip to content
Discussion options

You must be logged in to vote

Yes! Picocli has a rich programmatic model for exactly this. The key class is CommandSpec, which you can access via the @Spec annotation, and UsageMessageSpec which controls the help output.

Adding header/description/footer programmatically after construction:

CommandLine cmd = new CommandLine(new MyCommand());
cmd.getCommandSpec().usageMessage()
    .header("My Command - does amazing things%n",
            "See https://example.com/docs for full documentation%n")
    .description("A longer description here.%n",
                 "Supports multiple lines.%n")
    .footer("%nExamples:%n  my-command --option value%n");

If you want to set this inside the command class itself (useful for dynami…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@snicoll
Comment options

Answer selected by snicoll
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