I've been staring at the code for a while peppering with TODO statements where changes need to be made to allow the Groovy script engine to do its thing.
During startup, a CommandCenter object is created that does most of the delegating of work. It passes commands off to the CommandFactory to get the Command object, creates an instance of the Command and then runs it returning the result.
Right now the CommandFactory is hard coded to create a PredefinedCommandFactory object. This seems to just parse a properties file which contains names of commands and their corresponding classnames. These are put in a map of name to classname and used to create another factory called TypeMapCommandFactory which creates instances of commands based on the name requested and the classname in the map, throwing exceptions if they are missing.
In PredefinedCommandFactory, the TypeMapCommandFactory is held as an instance field called "delagate". There may have been grander plans for the PredefinedCommandFactory and the CommandFactory in general as it seems overly abstract, but it does provide a great place to put in my own CommandFactory.
My CommandFactory will be able to take in a command name and look up whether a Groovy script exists with that name in the scripts directory, however it was configured. I'm not sure whether or not built in commands or scripts will take precedence during name collisions. That might even be an exception as its too weird to want to do on purpose.
I intend to leave PredefinedCommandFactory in place and change its implementation to check with both the GroovyScriptCommandFactory and the TypeMapCommandFactory to return the Command.
Next up, besides actually doing that, is to create a base GroovyScriptCommand from which the scripts will inherit.