@@ -15,6 +15,16 @@ include::{snippets}/OptionSnippets.java[tag=option-without-annotation]
|
||||
----
|
||||
====
|
||||
|
||||
`Option` annotation can be used to define an option name if you
|
||||
don't want it to be same as argument name.
|
||||
|
||||
====
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/OptionSnippets.java[tag=option-with-option-annotation]
|
||||
----
|
||||
====
|
||||
|
||||
`@ShellOption` annotation can be used to define an option name if you
|
||||
don't want it to be same as argument name.
|
||||
|
||||
|
||||
@@ -21,12 +21,13 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.shell.command.CommandRegistration;
|
||||
import org.springframework.shell.command.CommandRegistration.OptionArity;
|
||||
import org.springframework.shell.command.CommandRegistration.OptionNameModifier;
|
||||
import org.springframework.shell.command.annotation.Option;
|
||||
import org.springframework.shell.standard.ShellMethod;
|
||||
import org.springframework.shell.standard.ShellOption;
|
||||
|
||||
public class OptionSnippets {
|
||||
|
||||
class Dump1 {
|
||||
class Dump1Legacy {
|
||||
// tag::option-with-annotation[]
|
||||
public String example(@ShellOption(value = { "--argx" }) String arg1) {
|
||||
return "Hello " + arg1;
|
||||
@@ -34,6 +35,14 @@ public class OptionSnippets {
|
||||
// end::option-with-annotation[]
|
||||
}
|
||||
|
||||
class Dump1 {
|
||||
// tag::option-with-option-annotation[]
|
||||
public String example(@Option(longNames = "argx") String arg1) {
|
||||
return "Hello " + arg1;
|
||||
}
|
||||
// end::option-with-option-annotation[]
|
||||
}
|
||||
|
||||
class Dump7 {
|
||||
// tag::option-with-annotation-without-prefix[]
|
||||
public String example(@ShellOption(value = { "argx" }) String arg1) {
|
||||
|
||||
Reference in New Issue
Block a user