File tree 2 files changed +20
-1
lines changed
test/java/org/springframework/shell/docs 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]
15
15
----
16
16
====
17
17
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
+
18
28
`@ShellOption` annotation can be used to define an option name if you
19
29
don't want it to be same as argument name.
20
30
Original file line number Diff line number Diff line change 21
21
import org .springframework .shell .command .CommandRegistration ;
22
22
import org .springframework .shell .command .CommandRegistration .OptionArity ;
23
23
import org .springframework .shell .command .CommandRegistration .OptionNameModifier ;
24
+ import org .springframework .shell .command .annotation .Option ;
24
25
import org .springframework .shell .standard .ShellMethod ;
25
26
import org .springframework .shell .standard .ShellOption ;
26
27
27
28
public class OptionSnippets {
28
29
29
- class Dump1 {
30
+ class Dump1Legacy {
30
31
// tag::option-with-annotation[]
31
32
public String example (@ ShellOption (value = { "--argx" }) String arg1 ) {
32
33
return "Hello " + arg1 ;
33
34
}
34
35
// end::option-with-annotation[]
35
36
}
36
37
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
+
37
46
class Dump7 {
38
47
// tag::option-with-annotation-without-prefix[]
39
48
public String example (@ ShellOption (value = { "argx" }) String arg1 ) {
You can’t perform that action at this time.
0 commit comments