I've been using CLI 1 for a while and I noticed that there's been renewed
interest in developing CLI2.  I was wondering how people are currently using
CLI, and whether I'm using it properly?

Most of the command line apps that I've developed do more than one thing.
In order to make it easier to plugin more functionality I use a basic
Command pattern.  Each plugin interface looks something like this:

Command
+ isValid(options: Options):boolean
+ getDescription():String
+ execute(options:Options):void
+ getPrimaryOption():Option

Each command has a primaryOption which uniquely identifies the command from
the command line.  For example, if you have a command which scales images,
then it might be identified by the --scale option.

The main application is responsible for discovering and loading all plugins
at runtime (using the SPI mechanism), determining which plugin to execute,
and printing out help information.  It also invokes the command by first
invoking the command's isValid method to validate the input before invoking
its execute method.

I'm curious if other people are using CLI in a similar manner, or if people
create separate CLI applications for each piece of functionality?

Regards,


-- 
Mark Fortner

blog: http://www.jroller.com/phidias

Reply via email to