Skip to content

Commit

Permalink
fix: display required only if no default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Di Falco committed Aug 9, 2023
1 parent 9529dcc commit 28e5d29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@ info(model) ::= <%
<if(model.maskedInput)>
<model.maskedInput>
<else>
<if(model.required)>
<("[Required]"); format="style-value">
<endif>
<if(model.defaultValue)>
<("[Default "); format="style-value"><model.defaultValue; format="style-value"><("]"); format="style-value">
<elseif(model.required)>
<("[Required]"); format="style-value">
<endif>
<endif>
<else>
<if(model.input)>
<model.input>
<else>
<if(model.required)>
<("[Required]"); format="style-value">
<endif>
<if(model.defaultValue)>
<("[Default "); format="style-value"><model.defaultValue; format="style-value"><("]"); format="style-value">
<elseif(model.required)>
<("[Required]"); format="style-value">
<endif>
<endif>
<endif>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@
import org.springframework.shell.standard.AbstractShellComponent;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
import org.springframework.util.StringUtils;

@ShellComponent
public class ComponentCommands extends AbstractShellComponent {

@ShellMethod(key = "component string", value = "String input", group = "Components")
public String stringInput(boolean mask, boolean required) {
StringInput component = new StringInput(getTerminal(), "Enter value", null);
public String stringInput(boolean mask, boolean required, @ShellOption(defaultValue = ShellOption.NULL) String defaultValue) {
StringInput component = new StringInput(getTerminal(), "Enter value", defaultValue);
component.setResourceLoader(getResourceLoader());
component.setTemplateExecutor(getTemplateExecutor());
component.setRequired(required);
Expand Down

0 comments on commit 28e5d29

Please sign in to comment.