Commands
Core annotations and patterns for defining CLI commands, options, and argument handling in Crest.
Crest turns Java methods into CLI commands through a small set of annotations. A method annotated with @Command becomes a command. Its parameters become options and positional arguments. The framework handles parsing, type conversion, validation, and help generation automatically.
This section covers everything you need to define and organize commands:
- Annotations –
@Command,@Option,@Default, and@Requiredform the foundation of every CLI tool built with Crest. - Options Classes – Bundle related options into reusable
@Optionsclasses and compose them across commands. - Command Groups – Organize commands into groups with sub-commands using class-level
@Command. - Return Types – Choose from
String,StreamingOutput,PrintOutput,Stream, and more to control command output. - I/O Streams – Inject
stdin,stdout, andstderrinto commands with@In,@Out, and@Err.
Annotations
The core annotations for defining commands, options, defaults, and required parameters in Crest.
Options Classes
Bundle related options into reusable classes with @Options, compose them across commands, and use @GlobalOptions.
Command Groups
Organize commands into groups and sub-commands using class-level @Command annotations.
Return Types
Supported return types for Crest commands including String, StreamingOutput, PrintOutput, Stream, and void.
I/O Streams
Inject stdin, stdout, and stderr into Crest commands using @In, @Out, and @Err annotations.