package com.obidea.semantika.cli2.command;

import com.obidea.semantika.cli2.runtime.ConsoleSession;

public class CommandFactory
{
   public static Command create(String command, ConsoleSession session) throws Exception
   {
      if (startsWith(command, Command.SELECT)) {
         return new SelectCommand(command, session);
      }
      else if (startsWith(command, Command.SET_PREFIX)) {
         return new SetPrefixCommand(command, session);
      }
      else if (startsWith(command, Command.SHOW_PREFIXES)) {
         return new ShowPrefixesCommand(command, session);
      }
      throw new Exception("Unknown command"); //$NON-NLS-1$
   }

   private static boolean startsWith(String command, String keyword)
   {
      return command.startsWith(keyword) || command.startsWith(keyword.toUpperCase());
   }
}

@@ -93,16 +93,82 @@
 Session;
+%0Aimport com.obidea.semantika.cli2.runtime.UnknownCommandException;
 %0A%0Apublic
@@ -270,16 +270,30 @@
  throws 
+UnknownCommand
 Exceptio
@@ -679,35 +679,32 @@
 new 
-Exception(%22
 Unknown
- c
+C
 ommand
-%22
+Exception(
 ); /

Use CommandUnknown exception in the method create.