Legacy Annotation
具有参数的目标方法会自动使用匹配的参数名称进行注册。
Having a target method with argument is automatically registered with a matching argument name.
Unresolved include directive in modules/ROOT/pages/options/basics/legacyannotation.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/OptionSnippets.java[]
如果您不希望它与参数名称相同,则可以使用 @ShellOption
注解来定义选项名称。
@ShellOption
annotation can be used to define an option name if you
don’t want it to be same as argument name.
Unresolved include directive in modules/ROOT/pages/options/basics/legacyannotation.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/OptionSnippets.java[]
如果未定义选项名称的前缀,即 -
或 --
,它将从 ShellMethod#prefix 中被识别。
If option name is defined without prefix, either -
or --
, it is discovered
from ShellMethod#prefix.
Unresolved include directive in modules/ROOT/pages/options/basics/legacyannotation.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/OptionSnippets.java[]