void (final String t) { /* * We need to: 1) parse input 2) fetch command 3) split its arguments. */ final PsiFileFactory fileFactory = PsiFileFactory.getInstance(myModule.getProject()); final CommandLineFile file = PyUtil.as(fileFactory.createFileFromText(CommandLineLanguage.INSTANCE, t), CommandLineFile.class); if (file == null) { return; } final String commandName = file.getCommand(); final List<String> commandAndArgs = Arrays.asList(EMPTY_SPACE.split(file.getText().trim())); // 1 because we need to remove command which is on the first place final List<String> args = (commandAndArgs.size() > 1 ? commandAndArgs.subList(1, commandAndArgs.size()) : Collections.emptyList()); for (final Command command : myCommands) { if (command.getName().equals(commandName)) { command.execute(commandName, myModule, args, myConsole); return; } } if (myDefaultExecutor != null && !commandAndArgs.isEmpty()) { // Unknown command execution is delegated to default executor myDefaultExecutor.execute(commandAndArgs.get(0), myModule, args, myConsole); } else { myConsole.print(PyBundle.message("commandLine.commandNotFound", commandName), ConsoleViewContentType.ERROR_OUTPUT); myConsole.print("", ConsoleViewContentType.SYSTEM_OUTPUT); } }