2008-04-04 03:14:11 UTC
First, I think that Natural CLI is absolutely brilliant. Great job!
But... I'm either confused, or having a problem. (probably confused)
When I create a simple command processor (further below) and pass it 'help' on the command line (without the quotes of course), I get the following output.
org.naturalcli.Syntax@156ee8e
Shows the commands help on plain text.
org.naturalcli.Syntax@47b480
Says hello.
I think the issue may be in the HelpCommandExecutor method, but then again, I'm probably confused.
Thanks for any help, and keep up the good work.
Paul
My example code is as follows:
package test.cli;
import java.util.HashSet;
import java.util.Set;
import org.naturalcli.Command;
import org.naturalcli.ExecutionException;
import org.naturalcli.ICommandExecutor;
import org.naturalcli.InvalidSyntaxException;
import org.naturalcli.NaturalCLI;
import org.naturalcli.ParseResult;
import org.naturalcli.commands.HelpCommand;
public class main {
public static void main(String[] args) {
try {
// Create the set for the commands
Set<Command> cs = new HashSet<Command>();
// Create the commands
cs.add(new HelpCommand(cs));
cs.add(new Command("hello world",
"Says hello.",
new ICommandExecutor ()
{ public void execute(ParseResult pr )
{ System.out.println("Hello world!"); }
}
));
// Execute
new NaturalCLI(cs).execute(args);
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}