Add better support for modified option names
- Longnames in a command option if modified via name modifier didn't provide enough backmapping info for command execution experience being accurate. - Add new getLongNamesModified() into CommandOption which is populated if name modifier is used. - Add more hints in CommandExecution for modified option names. - This should bring annotation and programmatic commands up to date. - Backport #777 - Fixes #782
This commit is contained in:
@@ -28,12 +28,13 @@ public class OptionNamingCommands {
|
||||
public static class LegacyAnnotation extends BaseE2ECommands {
|
||||
|
||||
@ShellMethod(key = LEGACY_ANNO + "option-naming-1", group = GROUP)
|
||||
public void testOptionNaming1Annotation(
|
||||
public String testOptionNaming1Annotation(
|
||||
@ShellOption("from_snake") String snake,
|
||||
@ShellOption("fromCamel") String camel,
|
||||
@ShellOption("from-kebab") String kebab,
|
||||
@ShellOption("FromPascal") String pascal
|
||||
) {
|
||||
return String.format("snake='%s' camel='%s' kebab='%s' pascal='%s' ", snake, camel, kebab, pascal);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,10 +66,16 @@ public class OptionNamingCommands {
|
||||
.withOption()
|
||||
.longNames("arg1")
|
||||
.nameModifier(name -> "x" + name)
|
||||
.required()
|
||||
// .required()
|
||||
.and()
|
||||
.withTarget()
|
||||
.consumer(ctx -> {})
|
||||
.function(ctx -> {
|
||||
String snake = ctx.getOptionValue("from_snake");
|
||||
String camel = ctx.getOptionValue("fromCamel");
|
||||
String kebab = ctx.getOptionValue("from-kebab");
|
||||
String pascal = ctx.getOptionValue("FromPascal");
|
||||
return String.format("snake='%s' camel='%s' kebab='%s' pascal='%s' ", snake, camel, kebab, pascal);
|
||||
})
|
||||
.and()
|
||||
.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user