Confirmation
确认组件要求用户进行一个简单的确认。它本质上是一个“是”或“否”的问题。
Unresolved include directive in modules/ROOT/pages/components/ui/confirmation.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/UiComponentSnippets.java[]
以下屏幕截图展示了确认组件的典型输出:
{"version": 2, "width": 85, "height": 8, "timestamp": 1645645867, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}} [1.590847, "o", "java -jar spring-shell-sample-commands.jar"] [2.774407, "o", "\r\n"] [4.560309, "o", "\u001b[?1h\u001b=\u001b[?2004h\u001b[33mmy-shell:>\u001b[0m"] [5.138757, "o", "\u001b[31mc\u001b[0m"] [5.267214, "o", "\u001b[31mo\u001b[0m"] [5.467126, "o", "\u001b[31mm\u001b[0m"] [5.674049, "o", "\u001b[31mp\u001b[0m"] [5.752663, "o", "\u001b[31mo\u001b[0m"] [5.917741, "o", "\u001b[31mn\u001b[0m"] [6.040844, "o", "\u001b[31me\u001b[0m"] [6.123068, "o", "\u001b[31mn\u001b[0m"] [6.277935, "o", "\u001b[31mt\u001b[0m"] [7.050283, "o", "\u001b[31m \u001b[0m"] [7.413917, "o", "\u001b[31mc\u001b[0m"] [7.568894, "o", "\u001b[31mo\u001b[0m"] [7.664856, "o", "\u001b[31mn\u001b[0m"] [7.853492, "o", "\u001b[13D\u001b[1mcomponent confirmation\u001b[0m \u001b[K"] [8.698242, "o", "\r\r\n\u001b[?1l\u001b>\u001b[?1000l\u001b[?2004l"] [8.745928, "o", "\u001b[?1h\u001b=\u001b[?25l"] [8.803411, "o", "\u001b[32;1m?\u001b[0m \u001b[97;1mEnter value\u001b[0m \u001b[2m(Y/n)\u001b[0m\r"] [13.769588, "o", "\u001b[?1l\u001b>\u001b[?12;25h\u001b[K"] [13.779021, "o", "\u001b[32;1m?\u001b[0m \u001b[97;1mEnter value\u001b[0m \u001b[34mtrue\u001b[0m\r\n"] [13.779319, "o", "Got value true\r\n"] [13.781245, "o", "\u001b[?1h\u001b=\u001b[?2004h\u001b[33mmy-shell:>\u001b[0m"] [15.955396, "o", "\u001b[1mcomponent confirmation\u001b[0m"] [16.743244, "o", "\r\r\n\u001b[?1l\u001b>\u001b[?1000l"] [16.743555, "o", "\u001b[?2004l"] [16.748638, "o", "\u001b[?1h\u001b=\u001b[?25l"] [16.754861, "o", "\u001b[32;1m?\u001b[0m \u001b[97;1mEnter value\u001b[0m \u001b[2m(Y/n)\u001b[0m\r"] [19.347907, "o", "\u001b[?1l\u001b>\u001b[?12;25h\u001b[K"] [19.355493, "o", "\u001b[32;1m?\u001b[0m \u001b[97;1mEnter value\u001b[0m \u001b[34mfalse\u001b[0m\r\n"] [19.356618, "o", "Got value false\r\n"] [19.3586, "o", "\u001b[?1h\u001b=\u001b[?2004h\u001b[33mmy-shell:>\u001b[0m"] [21.3586, "o", "\u001b[?1h\u001b=\u001b[?2004h\u001b[33mmy-shell:>\u001b[0m"]
上下文对象是 ConfirmationInputContext
。以下表格描述了它的上下文变量:
Key | Description |
---|---|
|
默认值 - |
|
父上下文变量(请参阅 TextComponentContext Template Variables)。 |