Use CommandContext as method parameter
- With annotation(@Command) model it's now possible to just add CommandContext and it will get resolved and doesn't cause it to appear as an option. - Fixes #779
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[[writing]]
|
||||
= Writing
|
||||
|
||||
ifndef::snippets[:snippets: ../../test/java/org/springframework/shell/docs]
|
||||
ifndef::snippets[:snippets: ../../../../src/test/java/org/springframework/shell/docs]
|
||||
|
||||
When something needs to get written into your console you can always
|
||||
use JDK's `System.out` which then goes directly into JDK's own streams.
|
||||
@@ -17,9 +17,17 @@ to return anything given `CommandContext` contains reference to
|
||||
include::{snippets}/WritingSnippets.java[tag=reg-terminal-writer]
|
||||
----
|
||||
|
||||
It's possible to autowire `Terminal` to get access to its writer.
|
||||
If using `@Command` you can get access to `CommandContext` and get
|
||||
`Terminal` from there.
|
||||
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/WritingSnippets.java[tag=anno-terminal-writer]
|
||||
----
|
||||
|
||||
It's possible to autowire `Terminal` to get access to its writer.
|
||||
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/WritingSnippets.java[tag=legacyanno-terminal-writer]
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user