-
Notifications
You must be signed in to change notification settings - Fork 394
Description
When upgrading to Spring Shell 4.0, all annotated command options that don't have a short name or long name specified fail the application initialisation.
If that change was intentional, it would be great to highlight it in the migration guide as a breaking change and update the JavaDocs as the @Option annotation states that those two arguments are optional.
Still, it would be great to restore the previous behaviour where the Java property name was used as the long name by default. That would be in line with other Spring projects like Spring MVC, where the @RequestParam doesn't require specifying a name if it matches the Java property name.
A command definition like the following with Spring Shell 3.4:
@Command(name = "test", description = "Test command.")
public void build(
@Option(description = "Some option.") String myOption,
) {
...
}would need to change to the following in 4.0:
@Command(name = "test", description = "Test command.")
public void build(
@Option(description = "Some option.", longName = "myOption") String myOption,
) {
...
}It's counterintuitive that the longName is not needed if a shortName is specified, since the shortName should be an additional way on top of the longName.
This works in 4.0 (no need to specify longName because a shortName is specified):
@Command(name = "test", description = "Test command.")
public void build(
@Option(description = "Some option.", shortName = "o") String myOption,
) {
...
}I'm available to help with a potential PR.