Home
About Me
Articles
Projects
Downloads
Java Quiz
Useful Links

JSHELL : CLI Framework for Java Applications


Jshell offers a basic shell to for applications that use a command line interface. Applications that need a command line interface, can plug-in their modules and configure the shell. The shell provides -

  1. Command line parsing for basic data types : boolean, int and text
  2. Options support : Commands can be set up with position in-sensitive options.
  3. Input Handling : Current build only support the System.in stream. Scripting support will be added later.

Usage

Steps to interface your application with the framework :
  1. Implement the net.sf.jshell.Command interface in your command handlers.
  2. Alter the classpath to include your libraries / applications.
  3. Add the commands to the configuration file (config.xml)

Configuration

Below is a sample configuration
    <jshell prompt="jshell2>">
        <commandConfig>
            <name>test</name>

            <name>te</name>
            <command impl="net.sf.jshell.TestCommand" />
            <options>
                <option name="v" longName="verbose1" optionType="boolean"  description="some verbose option"/>
                <option name="s" longName="something" description="something really unknown!"/>

            </options>
        </commandConfig>
    

All lines in the input that start with the words in the "name" element are delegated to the implementation provided in the corresponding "command" element. In the above case, any command line beginning with "te" or "test" will be parse and the parsed output will be used to invoke an instance of the class "net.sf.jshell.TestCommand". The command is configured with options "v" and "s". If the command is invoked with and option other than the ones configured, the command handler is not invoked.

Command Formats

The GNU command line format is assumed. Any command will have the following format -

  command -<option1 [option args]> -<option2 [option args]>  [command args]
  
The command options are not position sensitive. Any option should be prefixed with '-'. The option args should follow the corresponding option.

Dependencies

The framework uses digester to parse the configuration file. This in turn results in a chain of dependencies. Below is the list and the versions used in the build

Library Version
common-digester 1.5
Apache XML parser 2.6.2
Bean-Utils 1.6
common-collections 2.1
common-logging 1.0.3
Sun JNDI implementation for LDAP 1.2.1

Downloads

Site hosted by Angelfire.com: Build your free website today!