Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-220

provide a text entry option with remembered default values for 'wizard' like commands

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • karaf
    • None

    Description

      For example, imagine a command line "mvn release:prepare" or imagine a simple command which creates a new Java source file using some kind of template. You might want to allow folks to specify the package name to use, or release number to use for a command using an option. But if the option isn't supplied you might want to prompt the user with a guessed default value - which may well be fine most of the time, so users can just type 'enter' to accept the default, or provide a new value.

      e.g..

      imagine a "foo create mdb" command which creates a Message Driven Bean java class. If the user types the following in the console....

      $ foo create mdb bar
      Creating Message Driven Bean  class Bar
      package: [org.acme.foo]: _
      

      if the user hits enter, then the default value is accepted otherwise they can enter the value. Just like with "mvn release" where the plugin guesses decent values for all the options.

      Lets say the user enters "org.acme.foo.mdb" as the value then creates another MDB...

      $ foo create mdb bar
      Creating Message Driven Bean  class Bar
      package: [org.acme.foo]: org.acme.foo.mdb
      Created MDB in org.acme.foo.mdb.Bar
      
      $ foo create mdb another
      package: [org.acme.foo.mdb]: _
      

      Here the system has remembered what the user typed for an option so it can be defaulted in the next time.

      So given all the nice injection & annotations stuff in the Karaf console; I'm wondering if we can reuse the same options to from inside the execution of a command, be able to ask the user for an option (if it was not specified in the original command line) showing a default value - which if required can also be saved using the User Preferences stuff.

      something along the line of...

      public interface EntryForm {
      public boolean promptUser(Action action, String optionName, String prompt);
      }

      with maybe a separate API for use when the users response should be remembered in UserPreferences for next time the user executes a similar command.

      A great use case for the 'remembering' is when we create commands which code generate XML or Java code into a directory or package; which will likely remain the same for a project, but we may generate multiple instances of the same kind of thing. e.g. like creating entities or controllers in Rails, creating RouteBuilders in Camel or whatever

      UserPreferences stuff here:
      http://download.oracle.com/javase/1.5.0/docs/guide/preferences/index.html

      Attachments

        Activity

          People

            Unassigned Unassigned
            jstrachan James Strachan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: