The Text help generator, also referred to as the CLI help generator, is the default help generator built into the core Airline library. It provides a full range of help generator implementations that can be used to generate help for CLIs, command groups and commands.
The following implementations are available:
CliGlobalUsageGenerator
- Full blown CLI helpCliGlobalUsageSummaryGenerator
- Quick summary help for CLIsCliCommandGroupUsageGenerator
- Help for command groupsCliCommandUsageGenerator
- Help for individual commandsUsing CliGlobalUsageGenerator
:
Cli<ExampleRunnable> cli = new Cli<ExampleRunnable>(ShipItCli.class);
GlobalUsageGenerator<ExampleRunnable> helpGenerator = new CliGlobalUsageGenerator<>();
try {
helpGenerator.usage(cli.getMetadata(), System.out);
} catch (IOException e) {
e.printStackTrace();
}
Using CliGlobalUsageSummaryGenerator
:
Cli<ExampleRunnable> cli = new Cli<ExampleRunnable>(ShipItCli.class);
GlobalUsageGenerator<ExampleRunnable> helpGenerator = new CliGlobalUsageSummaryGenerator<>();
try {
helpGenerator.usage(cli.getMetadata(), System.out);
} catch (IOException e) {
e.printStackTrace();
}
Using CliCommandGroupUsageGenerator
:
Cli<ExampleRunnable> cli = new Cli<ExampleRunnable>(GroupCli.class);
CommandGroupUsageGenerator<ExampleRunnable> helpGenerator = new CliCommandGroupUsageGenerator<>();
try {
helpGenerator.usage(cli.getMetadata(), new CommandGroupMetadata[] { cli.getMetadata().getCommandGroups().get(0) }, System.out);
} catch (IOException e) {
e.printStackTrace();
}
Using CliCommandUsageGenerator
:
SingleCommand<Price> command = new SingleCommand<Price>(Price.class);
CommandUsageGenerator generator = new CliCommandUsageGenerator();
try {
generator.usage(null, null, "price", command.getCommandMetadata(), command.getParserConfiguration(), System.out);
} catch (IOException e) {
e.printStackTrace();
}
### Customisation
The main point of customisation for text based help is the number of columns to output i.e. the max number of character per line. This defaults to 79 which results in maximum line lengths of 80 characters barring some exceptions.
If you prefer you can create instances of the help generators with a different number of columns e.g.
CommandUsageGenerator = new CliCommandUsageGenerator(120);
This documentation is itself open source and lives in GitHub under the docs/ directory.
I am not a professional technical writer and as the developer of this software I can often make assumptions of
knowledge that you as a user reading this may not have. Improvements to the documentation are always welcome, if you
have suggestions for the documentation please submit pull requests to the main
branch.