JavaSh
Object shell with the power of java 6
Home › joolets

Joolets


Screenshot of a JavaSh session

Joolets are the cmdlets of JavaSh. They are simple java classes with some methods that are called dynamically from the shell when is invoked their command.
The methods are these:

  • command()
    to take the command managed by class
  • help()
    to extract information and usage
  • main(String args[], PipedObject pobj)
    to execute the command
Is very easy programming new joolets for expand javash. This is a template that you can use to create your classes.

package joolets;
import exceptions.*;
import pipedobjects.*;
import javash.*;

/**
* @author
*/
public class FooJooLet {

// command managed by the class
final String command = "foo";

// help and info
final String info =
"Name:\n" +
"\tJooLet\n" +
"Type:\n" +
"\tJooLet\n" +
"Description:\n" +
"\tFoo description\n" +
"Options\n" +
"\tfoo = option foo\n";

// usage
final String usage = "Usage:\n\t" + command + " <options>\n";

/**
* Return the command managed by the class
*/
public String command() {
return command;
}

/**
* Return command info and help
*/
public String help() {
String info = this.info + this.usage;
return info;
}

/**
* Check if the command is managed by the class
* and exec it...
*/
public PipedObject main (String[] args, PipedObject pobj)
throws CmdExecException {

if(args.lenght < 2) {
ShellConsole.println(usage);
throw new CmdExecException();
}

//exec the command ...

return pobj;
}
}
javash needs improvements. If you send me your joolets I will be happy to include them as soon as possible in the package! The source code for all joolets is available for consultation (also via Web) on the database cvs.
It might be a good starting point ...