CommandParserUtils { public static AbstractCommand parseCommand(String commandLines, ExecutionContext sessionContext) throws ODPSConsoleException { commandLines = commandLines.trim(); if (commandLines.equals("")) { throw new ODPSConsoleException(ODPSConsoleConstants.INVALID_PARAMETER_E); } int index = commandLines.lastIndexOf(";"); if (index != commandLines.length() - 1) { throw new ODPSConsoleException(ODPSConsoleConstants.COMMAND_END_WITH); } OdpsDeprecatedLogger.getDeprecatedCalls().put("USER_COMMANDS :" + commandLines, 1L); List<String> commandLinelist = new AntlrObject(commandLines).splitCommands(); if (commandLinelist.size() == 0 && !commandLines.trim().startsWith("--")) { commandLinelist.add(commandLines.substring(0, index)); } List<AbstractCommand> odpsCommandList = new LinkedList<AbstractCommand>(); int i = 0; int step = sessionContext.getStep(); for (String command : commandLinelist) { i++; if (step > i) { continue; } command = command.trim(); if (command.equals("")) { continue; } parseInteractiveCommand(odpsCommandList, command, sessionContext, i); } if (step > i) { throw new ODPSConsoleException( "[Error] invalid NUM for option k, total query count include empty query: " + i); } if (odpsCommandList.size() == 1) { return odpsCommandList.get(0); } else { CompositeCommand compositeCommand = new CompositeCommand(odpsCommandList, "", sessionContext); return compositeCommand; } }  static String[] getCommandTokens(String cmd); static CommandLine getCommandLine(String[] args, Options opts); static CommandLine getCommandLine(String cmd, Options opts); static AbstractCommand parseOptions(String args[], ExecutionContext sessionContext); static void removeHook(List<String> optionList, ExecutionContext sessionContext); static AbstractCommand parseCommand(String commandLines, ExecutionContext sessionContext); static List<PluginPriorityCommand> getExtendedCommandList(); static Set<String> getAllCommandKeyWords(); static List<Completer> getCompleters(); static void printHelpInfo(List<String> keywords); static void loadPlugins(); static Class<? extends AbstractCommand> getClassFromPlugin(String commandName); static String[] getCommandArgs(String[] args);  }
@Test public void commandPaserTest() throws ODPSConsoleException { ExecutionContext ctx = ExecutionContext.init(); AbstractCommand command; command = CommandParserUtils.parseCommand(showTbaleCommandText, ctx); assertTrue(command instanceof CompositeCommand); }