Menu

Problems with HelpCommandExecutor

Help
2008-04-04
2013-04-23
  • Paul Hruska

    Paul Hruska - 2008-04-04

    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();
            }
        }
    }

     
    • Johan T

      Johan T - 2008-04-10

      Hi,

      I just submitted a bug report about this so, no, you're not confused. Apparently it's the Syntax class that's missing a toString(). I'm trying to fix it myself to be able to move on. Otherwise, it's a great little utility.

      Johan

       
    • Ferran Busquets

      Ferran Busquets - 2008-04-10

      Hi,

      First of all, thanks for your feedback and for summiting the bug. I'm going to see what is happening and I'll provide a new patched release soon.

      Thanks again!

      Ferran

       
    • Ferran Busquets

      Ferran Busquets - 2008-04-13

      HI,

      Just notice that there are a new release with the changes to this issue and others bug fixes.

      Thanks a lot for you feedback! If there are any other thing to solve or any feature request, it'll be welcome.

      best regards,

      Ferran

       

Log in to post a comment.

MongoDB Logo MongoDB