Support label with @Option

- Add `label` field into `@Option`. This sets option label if
  `label` field has any text.
- Fixes #732
This commit is contained in:
Janne Valkealahti
2023-05-01 17:11:03 +01:00
parent 755cf66350
commit a0ad3ad797
5 changed files with 57 additions and 11 deletions

View File

@@ -70,6 +70,13 @@ public @interface Option {
*/
String description() default "";
/**
* Return a label of the option.
*
* @return label of the option
*/
String label() default "";
/**
* Define option arity.
*

View File

@@ -251,6 +251,9 @@ class CommandRegistrationFactoryBean implements FactoryBean<CommandRegistration>
optionSpec.shortNames(shortNames.toArray(new Character[0]));
optionSpec.position(mp.getParameterIndex());
optionSpec.description(so.description());
if (StringUtils.hasText(so.label())) {
optionSpec.label(so.label());
}
int arityMin = so.arityMin();
int arityMax = so.arityMax();
if (arityMin > -1) {