File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
test/java/org/springframework/shell/docs Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff 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
1929don't want it to be same as argument name.
2030
Original file line number Diff line number Diff line change 2121import org .springframework .shell .command .CommandRegistration ;
2222import org .springframework .shell .command .CommandRegistration .OptionArity ;
2323import org .springframework .shell .command .CommandRegistration .OptionNameModifier ;
24+ import org .springframework .shell .command .annotation .Option ;
2425import org .springframework .shell .standard .ShellMethod ;
2526import org .springframework .shell .standard .ShellOption ;
2627
2728public 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 ) {
You can’t perform that action at this time.
0 commit comments