Register option without prefix
- While option should be defined i.e. using "--arg", discover prefix from ShellMethod#prefix and use that if just "arg" is defined. - Backport #575 - Fixes #577
This commit is contained in:
@@ -25,6 +25,16 @@ include::{snippets}/OptionSnippets.java[tag=option-with-annotation]
|
||||
----
|
||||
====
|
||||
|
||||
If option name is defined without prefix, either `-` or `--`, it is discovered
|
||||
from _ShellMethod#prefix_.
|
||||
|
||||
====
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/OptionSnippets.java[tag=option-with-annotation-without-prefix]
|
||||
----
|
||||
====
|
||||
|
||||
Programmatic way with `CommandRegistration` is to use method adding a long name.
|
||||
|
||||
====
|
||||
|
||||
@@ -23,12 +23,20 @@ public class OptionSnippets {
|
||||
|
||||
class Dump1 {
|
||||
// tag::option-with-annotation[]
|
||||
public String example(@ShellOption(value = { "argx" }) String arg1) {
|
||||
public String example(@ShellOption(value = { "--argx" }) String arg1) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
// end::option-with-annotation[]
|
||||
}
|
||||
|
||||
class Dump7 {
|
||||
// tag::option-with-annotation-without-prefix[]
|
||||
public String example(@ShellOption(value = { "argx" }) String arg1) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
// end::option-with-annotation-without-prefix[]
|
||||
}
|
||||
|
||||
class Dump2 {
|
||||
// tag::option-without-annotation[]
|
||||
public String example(String arg1) {
|
||||
|
||||
Reference in New Issue
Block a user