Squirrel
Squirrel is a lite task based command line interface application framework written in Java, and provides the functionality to run an application in both single-run and interactive mode.
Tasks are written and added to an application by mapping them to commands invoked from the command line interface.
Squirrel makes use of JLine to provide an interactive mode and therefore is not a pure Java implementation.
Download
| Squirrel 1.0 | squirrel-1.0.zip | Download |
| Squirrel 1.0 Source | squirrel-1.0-src.zip | Download |
Javadocs
Please see the online Javadocs for the API and source code.
Applications
Squirrel is currently in use by the following applications.
Creating Applications
Applications are created by implementing the Application interface. The abstract class AbstractApplication is provided to make this process easier.
The following class provides a skeleton Application implementation.
package my.package;
import uk.co.bedican.squirrel.*;
public class MyApplication extends AbstractApplication
{
public MyApplication()
{
}
/**
* The configure method is called when intialising the application.
* This is where tasks should be added to the application.
*/
protected void configure() throws ApplicationException
{
this.addTask("foo", new FooTask());
}
/**
* The java applications entry point.
* An ApplicationLoader is used to create the Application instance.
* If an argument of the value "-i" exists, the application
* will be run in interactive mode using JLine.
*/
public static void main(String[] args)
{
ApplicationLoader.run(MyApplication.class, args);
}
}
Creating Tasks
Tasks are created by implementing the Task interface. The abstract class AbstractTask is provided to make this process easier.
The following class provides a skeleton Task implementation.
package my.package;
import uk.co.bedican.squirrel.*;
import java.io.*;
import java.util.*;
public class MyTask extends AbstractTask
{
public MyTask()
{
}
/**
* The doInit method is called when the task is added to an application and
* configuring the description and help messages should be done here.
* This method is optional, a default empty implementation is provided within AbstractTask.
*/
protected void doInit() throws TaskException
{
this.setDescription("My task description");
this.setHelp("\n Usage:\n\t%name%\n\n This task does something wonderful.\n");
}
/**
* Called when this task is invoked from the command line interface.
* The first argument of the argument list will be the command name
* mapped to this task within the application.
*/
public void doRun(List<String> args) throws TaskException, IOException
{
this.getPrintStream().println("Hello world !");
}
}
Open Source
Squirrel makes use of the following open source libraries, any changes made will be listed here for download.
License
© Copyright 2010, 2012 Bedican Solutions
Redistribution and use of this software in source and binary forms, with or without modification, are permitted providing the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name bedican, bedican solutions nor the name of the author, may be used to endorse or promote any website or products without specific prior written permission. The name bedican is a trademark of bedican solutions.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
