StringInput masking
- Add a feature to define a mask character for StringInput which help when there's a need to as something sensitive. - This masks both input and result value.
This commit is contained in:
@@ -51,10 +51,13 @@ public class ComponentCommands extends AbstractShellComponent implements Resourc
|
||||
}
|
||||
|
||||
@ShellMethod(key = "component string", value = "String input", group = "Components")
|
||||
public String stringInput() {
|
||||
public String stringInput(boolean mask) {
|
||||
StringInput component = new StringInput(getTerminal(), "Enter value", "myvalue");
|
||||
component.setResourceLoader(resourceLoader);
|
||||
component.setTemplateExecutor(templateExecutor);
|
||||
if (mask) {
|
||||
component.setMaskCharater('*');
|
||||
}
|
||||
StringInputContext context = component.run(StringInputContext.empty());
|
||||
return "Got value " + context.getResultValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user