Files
spring-shell/spring-shell-docs/src/main/asciidoc/using-shell-options-definition.adoc
Janne Valkealahti 03a02a0615 Flatten docs structure
- Essentially remove "Using Spring Shell" and move
  its content one level up.
- Fixes #433
2022-07-06 09:36:36 +01:00

36 lines
906 B
Plaintext

[[using-shell-options-definition]]
=== Definition
ifndef::snippets[:snippets: ../../test/java/org/springframework/shell/docs]
Options can be defined within a target method as annotations in a method arguments
or with programmatically with `CommandRegistration`.
Having a target method with argument is automatically registered with a matching
argument name.
====
[source, java, indent=0]
----
include::{snippets}/OptionSnippets.java[tag=option-without-annotation]
----
====
`@ShellOption` 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-annotation]
----
====
Programmatic way with `CommandRegistration` is to use method adding a long name.
====
[source, java, indent=0]
----
include::{snippets}/OptionSnippets.java[tag=option-registration-longarg]
----
====