Skip to content

Commit fd73531

Browse files
committed
Document @option long name
- Relates #637
1 parent 07e08b3 commit fd73531

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

spring-shell-docs/src/main/asciidoc/using-shell-options-definition.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ include::{snippets}/OptionSnippets.java[tag=option-without-annotation]
1515
----
1616
====
1717

18+
`Option` annotation can be used to define an option name if you
19+
don't want it to be same as argument name.
20+
21+
====
22+
[source, java, indent=0]
23+
----
24+
include::{snippets}/OptionSnippets.java[tag=option-with-option-annotation]
25+
----
26+
====
27+
1828
`@ShellOption` annotation can be used to define an option name if you
1929
don't want it to be same as argument name.
2030

spring-shell-docs/src/test/java/org/springframework/shell/docs/OptionSnippets.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,28 @@
2121
import org.springframework.shell.command.CommandRegistration;
2222
import org.springframework.shell.command.CommandRegistration.OptionArity;
2323
import org.springframework.shell.command.CommandRegistration.OptionNameModifier;
24+
import org.springframework.shell.command.annotation.Option;
2425
import org.springframework.shell.standard.ShellMethod;
2526
import org.springframework.shell.standard.ShellOption;
2627

2728
public class OptionSnippets {
2829

29-
class Dump1 {
30+
class Dump1Legacy {
3031
// tag::option-with-annotation[]
3132
public String example(@ShellOption(value = { "--argx" }) String arg1) {
3233
return "Hello " + arg1;
3334
}
3435
// end::option-with-annotation[]
3536
}
3637

38+
class Dump1 {
39+
// tag::option-with-option-annotation[]
40+
public String example(@Option(longNames = "argx") String arg1) {
41+
return "Hello " + arg1;
42+
}
43+
// end::option-with-option-annotation[]
44+
}
45+
3746
class Dump7 {
3847
// tag::option-with-annotation-without-prefix[]
3948
public String example(@ShellOption(value = { "argx" }) String arg1) {

0 commit comments

Comments
 (0)