[[using-shell-options-optional]]
=== Optional Value
ifndef::snippets[:snippets: ../../test/java/org/springframework/shell/docs]

An option is either required or not and, generally speaking, how it behaves depends on
a command target.

Making option optional.

[source,java,indent=0,role="primary"]
.Programmatic
----
include::{snippets}/OptionSnippets.java[tag=option-optional-programmatic]
----

[source,java,indent=0,role="secondary"]
.Annotation
----
include::{snippets}/OptionSnippets.java[tag=option-optional-annotation]
----

[source,java,indent=0,role="secondary"]
.Legacy Annotation
----
include::{snippets}/OptionSnippets.java[tag=option-optional-legacyannotation]
----

Making option mandatory.

[source,java,indent=0,role="primary"]
.Programmatic
----
include::{snippets}/OptionSnippets.java[tag=option-mandatory-programmatic]
----

[source,java,indent=0,role="secondary"]
.Annotation
----
include::{snippets}/OptionSnippets.java[tag=option-mandatory-annotation]
----

[source,java,indent=0,role="secondary"]
.Legacy Annotation
----
include::{snippets}/OptionSnippets.java[tag=option-mandatory-legacyannotation]
----
