Announcement Announcement Module
No announcement yet.
How to read user Input from Console with Spring Shell Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to read user Input from Console with Spring Shell


    i wonder how the user can enter some input from the spring shell via console, e.g. a password or login:
    Tried to use:

    login = cons.readLine("%s", "Login: ");

    But after every key pressed input is already newline terminated - whats the way to get something from spring-shell from stdin - documentation does not mention anything about this?
    JLine does have its fingers on the stream, so how to get JLine stream control from a command?

    My current "really ugly hack" is to use this:

    private Shell shell;
    public void readSomething() {
      ConsoleReader reader = (ConsoleReader) FieldUtils.getProtectedFieldValue("reader", shell);
      reader.readline("Login: ");
    And whats the correct way to print something to the shell - e.g. a progress bar (using carriage returns without new lines) - how is that done?
    The "flash" looks something like it can be used for the latter, however how can the location be customized, positioning is a problem in the right corner per default, how can the implementation be switched?
    Last edited by tkrah; May 6th, 2014, 09:48 AM.