- Parsing Changes
- New
ParserErrorHandlerinterface for handling non-fatal parser errors (#53)FailFast- Classic behaviour, throw as soon as error encounteredFailAll- Collect and aggregate non-fatal errors and throw as single errorCollectAll- Collect all non-fatal errors- New
ParseResult<T>interface for representing parsing result and accessing success status and errors (if any) - Support for customising type converter on a per-option/arguments basis (#54)
- New
- Help Changes
- Added
showHelpIfErrors()method toHelpOptionfor use with error handlers which collect errors e.g.CollectAll(#53)
- Added
- Annotation Changes
- New
errorHandlerfield on@Parserannotation for specifying error handler, defaults toFailFastfor backwards compatible behaviour (#53) - New
flagNegationPrefixfield on@Parserto allow specifying that if a flag option (zero arity option) name starts with that prefix the value should be set tofalseas opposed to setting flags totrueas is the normal behaviour (#63) - New
descriptionfield on@Patternto provide human readable explanation of regular expression restriction intent (#48) - Noted in Javadoc that
@Versionsupports both properties and Manifest files as data sources (#56) - Use new
typeConverterProviderfield on@Option/@Argumentsto customise the type converter for a field (#54)- Variety of built in converters provided for supporting more complex number formats
- Alternative Bases:
Hexadecimal,OctalandBinary - Abbreviations:
KiloAs1000,KiloAs1024
- Alternative Bases:
- Variety of built in converters provided for supporting more complex number formats
- New
- Bug Fixes
- Fixed a possible infinite loop in parsing when a group contains both sub-groups and commands (#55)
- Fixed possible non-deterministic ordering of option and arguments help hints (#50)
- Annotation Changes
- Removed deprecated
arityfrom@Arguments, the@MaxOccurrencesrestriction annotation (and its related annotations) provide for much finer grained control than this property did - Global restrictions can now be specified via annotations
- Removed deprecated
- Help Changes
- Removed the deprecated RONN help generators (use
airline-help-manorairline-help-markdowninstead)- This removes the
airline-help-ronnmodule (Breaking)
- This removes the
- Removed the deprecated RONN help generators (use
- Restriction Changes
- New
GlobalRestrictionsFactoryinterface and corresponding registry inRestrictionsRegistry- Uses
ServiceLoaderfor automatic discovery, provide aMETA-INF/services/com.github.rvesse.airline.restrictions.factories.GlobalRestrictionFactoryfile to specify global restriction factories
- Uses
- Global restrictions can now be specified by adding annotations to
@Cliannotated classes - Improved
OptionRestrictionandArgumentsRestrictioninterfaces- Old
postValidate()method becomesfinalValidate() - Revised
postValidate()method with better type signature that takes the converted value
- Old
- Support partial restrictions i.e. restrictions only apply to some of the values for
@Optionor@Argumentsfields- Specified via
@Partial/@Partialsannotations in addition
- Specified via
- New
- Parser Changes
- Improve how restrictions for options and arguments are enforced
- Options must always receive precisely their
arityin values or aParseOptionMissingValueExceptionis thrown (at least with the built-in parsers)
- Bug Fixes
ManCommandUsageGeneratorcould incorrectly indent the arguments portion of the options list if both visible and hidden options are present- Man help output could fail in the options section if there were no visible options but some hidden options present
- Annotation Changes
- Marked defunct fields of
@Argumentsannotation as deprecated - Marked various annotations as
@Documentedso they are included in JavaDoc output - All fields of
@Aliasannotation are now required
- Marked defunct fields of
- Parser Changes
- Made internal helper class
ConvertResultpublic to make it easier to extend theDefaultTypeConverter
- Made internal helper class
- Documentation Improvements
- New website in progress at http://rvesse.github.io/airline/
- Module Additions and Changes
- New
airline-help-manmoduleManSectionsmoved into this module (Breaking)
- RONN help generators moved to
airline-help-ronnmodule (Breaking)- All RONN generators are marked as
@deprecatedsince they are superseded by the Man and Markdown format generators
- All RONN generators are marked as
- HTML help generators moved to
airline-help-htmlmodule (Breaking) - Bash help generators moved to
airline-help-bashmodule (Breaking)CompletionBehaviourmoved into this module (Breaking)
- New
airline-help-markdownmodule for generating Markdown help
- New
- Help Improvements
- New direct man page generation via
ManCommandUsageGenerator,ManGlobalUsageGeneratorandManMultiPageGlobalUsageGeneratorprovided in theairline-help-man- These are intended to replace use of the existing RONN generators for generating Man pages
- New direct Markdown generation via
MarkdownCommandUsageGenerator,MarkdownGlobalUsageGeneratorandMarkdownMultiPageGlobalUsageGenerator- These are intended to replace use of the existing RONN generators for generating Markdown help
CommandUsageGeneratorhas new overloads that take aParserMetadata<T>object, old overloads are deprecated in favour of these. This allows generators to produce more accurate help in some circumstances.- Switched to using
ServiceLoaderto discover available help section factories avoiding the need to explicitly register these withHelpSectionRegistry- Provide a
META-INF/services/com.github.rvesse.airline.help.sections.factories.HelpSectionFactoryfile to specify help section factories HelpSectionRegistrymoved to packagecom.github.rvesse.airline.help.sections.factories(Breaking)HelpSectionFactorynow required to implement asupportedAnnotations()method to declare the annotations it can turn intoHelpSectioninstances (Breaking)
- Provide a
- New
@Copyrightand@Licenseannotations for adding copyright and license statements to help - New
@ProseSectionannotation for adding a custom prose section to help - Improved presentation of help hint for options/arguments annotated with
@Port - Improved presentation of help hints for numeric ranges, they no longer show min/max if those are set to the min/max of their respective numeric types and the range is inclusive
- Improved presentation of help hint for single value ranges
- New direct man page generation via
- Metadata Changes
- User alias configuration are now preserved on a
UserAliasesSource<T>class which is accessible viaParserMetadata<T>.getUserAliasesSource() completionBehaviourandcompletionCommandare no longer fields on the@Optionand@Argumentsannotation. Instead use the@BashCompletionannotation from theairline-help-bashmodule
- User alias configuration are now preserved on a
- Restriction Improvements
- New
@Pathrestriction for specifying that an arguments value is a path to a file/directory and applying restrictions on the path/file that should be enforced e.g. must exist, readable etc. - New
@MutuallyExclusiveWithrestriction for specifying that only one of some set of options may be specified but that those options are optional, this is thus a less restrictive version of@RequireOnlyOne - Switched to using
ServiceLoaderto discover available restriction factories avoiding the need to explicitly register these with theRestrictionRegistry- Factories are now required to implement a method indicating what annotations they can translate into restrictions (Breaking)
- Provide a
META-INF/services/com.github.rvesse.airline.restrictions.factories.OptionRestrictionFactoryfile to specify option restriction factories - Provide a
META-INF/services/com.github.rvesse.airline.restrictions.factories.ArgumentsRestrictionFactoryfile to specify argument restriction factories
- New
- Bug Fixes
@Portrestriction would incorrectly reject valid values when applies to@Argumentsannotated fields- Restrictions could report incorrect argument title when applied to arguments with multiple titles
- Bug Fixes
- Fix
@MinLengthbeing an exclusive restriction i.e. value had to be greater than given length when intention was that value should be at least the given length
- Fix
- Documentation
- Add missing Javadocs to new annotations
2.0.0 represents substantial breaking changes over 1.x which were made to make the library more configurable and extensible. We strongly recommend reading the included Migrating.md for notes on how to migrate existing Airline powered CLIs forward.
- Dependency Changes
- Removed Guava
- Added Apache Commons Collections 4
- Builder improvements
- All parser related options on
CliBuilderare now moved toParserBuilderwhich is access by calling.withParser()on theCliBuilderinstance - Groups now support sub-groups and
GroupBuilderprovideswithSubGroup()andgetSubGroup()for working with these
- All parser related options on
- Annotation Changes
- Various fields were removed from existing annotations in favour of moving them to separate annotations
@Commandremovesexamples,discussion,exitCodesandexitCodeDescriptions@Optionremovesrequired,allowedValuesandignoreCase@Groupcan now be used to create sub-groups by inserting spaces into group names e.g.@Group(name = "foo bar")creates a groupfoowith a sub-groupbarand applies any other configuration given to the sub-group- New
@Cliannotation can be used to define a CLI entirely declaratively - New
@Parserannotation can be used to customise parser for CLIs created withSingleCommandor as a field on a@Cliannotation @Argumentsremovesrequired
- New annotations for adding extended help to commands
@Discussionto add discussion, this replaces thediscussionfield of the@Commandannotation@Examplesto add examples, this replaces theexamplesfield of the `@Command annotation@ExitCodesto add exit codes, this replaces theexitCodesandexitCodeDescriptionsfields of the- Custom extended help sections can be created and registered such that they are automatically discovered by Airline
- New restriction annotations for expressing restrictions on options and arguments
@Requiredto indicate required options/arguments, this replaces therequiredfield on the@Optionand@Argumentsannotations- New
@RequiredOnlyIffor conditionally requiring an option if another option is present - New
@RequireSomefor requiring at least one from some set of options - New
@RequireOnlyOnefor requiring exactly one from some set of options @AllowedRawValuesfor limiting the raw string values an option can receive, this replaces theallowedValuesandignoreCasefields on the@Optionannotation- New
@AllowedValuesfor limiting the converted values an option can receive - New
@MaxLengthand@MinLengthfor limiting the length of the raw string values an option can receive - New
@MinOccurrences,@MaxOccurrencesand@Oncefor limiting how many times an option can appear - New
@LongRange,@IntegerRange,@ShortRange,@ByteRange,@DoubleRange,@FloatRangeand@LexicalRangefor indicating that arguments once converted to the appropriate value type must fall within a given range - New
@Portfor restricting options to some port range(s) - New
@NotEmptyand@NotBlankfor requiring the raw string values be non-empty or non-blank (not all whitespace) - New
@Patternfor requiring that the raw string values conform to some regular expression - New
@Unrestrictedto indicate that restrictions inherited from an overridden option should be removed - Custom restrictions can be created and registered such that they are automatically enforced by Airline
- Various fields were removed from existing annotations in favour of moving them to separate annotations
- Parser Improvements
TypeConverteris now an interface and configurable i.e. allows you to control how Airline turns raw string values into Java objects- Option parsing styles are now fully configurable (default behaviour remains as 1.x which uses the first 3 styles):
- Classic GNU Get Opt Style
- Long GNU Get Opt Style
- Standard whitespace separated style
- List value style i.e.
--name a,b,cfor higher arity options - Pair value style i.e.
--name a=bfor arity 2 options - Users can define and register their own custom option parsers as desired
- Alias Improvements
- Can now support optional alias chaining i.e. aliases can reference other aliases
- Metadata Improvements
- Parsing specific metadata moved to
ParserMetadataclass which is accessible viaGlobalMetadata.getParserConfiguration() GlobalMetadatais now a generic class taking the command type as the type parameter
- Parsing specific metadata moved to
- Help Improvements
- New
HelpHintinterface which is used by restrictions to provide help - New
HelpSectioninterface for adding custom help sections to commands - More advanced and flexible formatting of extra help hints and sections in all existing generators
- Help supports providing help for sub-groups, help for groups will include information about available sub-groups
- New
- Various minor improvements from Christian Raedel
- Long style option parser
--name=valuenow also accepts colon separated values e.g.--name:value allowedValueson@Optioncan now be set to use case insensitive comparisonTrueColorcan be instantiated from a hex value
- Long style option parser
- Fix regression in
RonnCommandUsageGenerator
- Code Structure Refactoring
- Root package is now
com.github.rvesse.airline - Main library now lives under
lib/in source control - New examples module under
examples/in source control
- Root package is now
- Annotation Improvements
@Groupcan now be marked ashiddendiscussionparameter of@Commandis now aString[]rather than a single string making it easier to specify long descriptions
- CLI Improvements
- User defined command aliases are now supported
- CLI builder classes are now public and have their own
builderpackage - Parser Improvements
- All parser errors in the
parserpackage have public constructors
- All parser errors in the
- Help Improvements
- Help generators can now optionally display hidden commands and options
Help.help()static improved:- Respects command abbreviation when enabled
- Additional overloads for enabled output of hidden commands and options
- Bash completion fixes and improvements:
- Default command and default group command completion now included
- Functions for default group commands (i.e. top level commands) are no longer missing if there are also groups present
- Fixed a bug with hidden options not displaying in synopsis even when including hidden options was enabled
HelpOptionimproved:- Generated help will include program and group name where applicable
- It can now be used to show help with an arbitrary usage generator
showHelpIfRequested()guarantees to only display help onceshowHelp()can be used to display help regardless
- Command usage generators now print each item in the discussion as a separate paragraph
- IO Improvements
- New
com.github.rvesse.airline.iopackage with useful helper stuff for doing advanced console IO - Support for colorised output streams and writers:
- Basic ANSI Colors (8 Colors, normal and bright variants)
- 256 Colors (Basic ANSI Colors plus 3 colour palettes plus grayscale palette) - See color chart for more detail
- True Color (24 bit colour i.e. 16 million colours) - Many terminals may not support this mode
- Includes basic text decorations e.g. bold, underline
- New
- Annotation Improvements
Argumentsimprovements- An
aritycan now be specified to set the maximum arity for arguments and throws aParseTooManyArgumentsExceptionif too many arguments are seen
- An
- New
DefaultOptionannotation- Allows a field already annotated with
@Optionto also be marked as the default option under certain circumstances. This allows one option to be specified arguments style i.e. the-nor--namecan be omitted provided only one field is annotated this way, it has an arity of 1 and no fields are annotated with@Arguments
- Allows a field already annotated with
- Bash Completion Fixes
- Bash Completion Scripts for CLI that use groups are now valid Bash and function correctly
- Generated scripts use more unique function names to avoid clashes between different airline generated completion scripts
- CLI Improvements
- CLIs can now have command abbreviation enabled which allows users to only type part of the command name provided that the portion typed is unambiguous
- CLIs can now have option abbreviation enabled which allows users to only type part of the option name provided that the portion typed is unambiguous
- Package Refactoring
- Parser functionality moved into
io.airlift.airline.parserpackage
- Parser functionality moved into
- Help improvements
- Refactored various usage generators to make them easier to extend
- Annotation improvements
Commandimprovements- Added
exitCodesandexitDescriptionsfor declaring the exit codes a command can produce and their meanings
- Added
- Help improvements
- All command help generator now include exit code information if declared for a command via the
exitCodesandexitDescriptionsproperties - Add new
RonnMultiPageGlobalUsageGeneratorwhich generates a top level overview RONN page and then individual RONN files for each sub-command - Fix broken sort order of commands and groups in various help generator implementations
- Add documentation of
allowedValuesto all help generators - Fix typo in presentation of
--option in various help generators - Fix presentation of
examplesto avoid need for users to use markup in their annotations
- All command help generator now include exit code information if declared for a command via the
- Forked from upstream repository
- Group ID changed to
com.github.rvesse - Currently package names remain same as upstream (bar the help system) to make it easy to migrate existing apps to this fork.
- Please note that future releases will change the package names to align with the Group ID.
- Group ID changed to
- Annotation improvements
Optionimprovements:allowedValuesproperties is actually enforced and producesParseOptionIllegalValueExceptionif an invalid value is received- New
overrideandsealedproperties allowing derived commands to change some properties of the annotation - Overridden options may change the type when it is a narrowing conversion
- New
completionBehaviourandcompletionCommandproperties allowing defining behaviours for the purposes of completion script generators
Argumentsimprovements- New
completionBehaviourandcompletionCommandproperties allowing defining behaviours for the purposes of completion script generators
- New
Groupannotation for specifying groupsCommandannotation supports discussion and examples
- Help system improvements
- Most portions moved to
io.airlift.airline.helppackage - Help printing respects new lines allowing them to be used in longer descriptions
- Support for additional examples and discussion sections in command help
- Abstracted out help generation into interfaces with multiple concrete implementations:
- Command Line (the existing help system)
- Ronn
- HTML
- Bash auto-completion script
- Most portions moved to
- Support for Command Factories