Using default help command

Adding default help command

To add support for default "help" command, using declared documentation, add DefaultHelpCommand.class command class:

        final AnnottationAwareSetup setup = new AnnottationAwareSetup("DemoFileLister");
        setup.addSubCommand(DefaultHelpCommand.class);

Note that help command works just like any other command.

Global help

Shows

  • generic synopsis
  • list of commands, with short descriptions
  • list of global options (if any)

    Look at the output of minicalc --help:

    Usage:
       minicalc <subcommand> [options] [args]
    
    Available subcommands:
       help     shows help for the whole app. or for specified command
       log      computes logarithm of given argument
       minus    computes operand1 - operand2
       plus     computes sum of all given numbers
    
    Type 'minicalc help <subcommand>' for help on a specific subcommand
    

Command-specific help

Shows

  • command synopsis
  • list of valid options (if any)
  • list of valid global options (if any)

    Look at the output of minicalc --help log:

    Subcommand 'log': computes logarithm of given argument
    
    Usage:
       minicalc log [options] <arg>
    
    Valid options:
       -b [--base] <base>  the base of the logarithm