Add confirmation component

- New ConfirmationInput component
- Add missing native resource config for templates.
- Add sample "component confirmation", use flag --no
  to switch default from yes to no.
- Fixes #366
This commit is contained in:
Janne Valkealahti
2022-02-11 10:00:16 +00:00
parent 2f4209785e
commit 785a9268e3
5 changed files with 435 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
"resources": {
"includes": [
{
"pattern": "org/springframework/shell/component/.*.stg"
}
]
}
}

View File

@@ -0,0 +1,40 @@
// message
message(model) ::= <%
<if(model.message && model.hasMessageLevelError)>
<(">>>"); format="level-error"> <model.message; format="level-error">
<elseif(model.message && model.hasMessageLevelWarn)>
<(">>"); format="level-warn"> <model.message; format="level-warn">
<elseif(model.message && model.hasMessageLevelInfo)>
<(">"); format="level-info"> <model.message; format="level-info">
<endif>
%>
// info section after '? xxx'
info(model) ::= <%
<if(model.defaultValue)>
<("(Y/n)"); format="item-disabled">
<else>
<("(y/N)"); format="item-disabled">
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
>>
// component result
result(model) ::= <<
<question_name(model)> <model.resultValue; format="value">
>>
// component is running
running(model) ::= <<
<question_name(model)> <info(model)>
<message(model)>
>>
// main
main(model) ::= <<
<if(model.resultValue)><result(model)><else><running(model)><endif>
>>