Document @Option long name

- Relates #637
This commit is contained in:
Janne Valkealahti
2023-02-24 12:18:16 +00:00
parent 07e08b36a7
commit fd73531986
2 changed files with 20 additions and 1 deletions

View File

@@ -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.

View File

@@ -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) {