@Override public CommandContainer<?> getCommand(String name, String completeLine) throws CommandNotFoundException { waitUntilStarted(); ShellContextImpl shellContext = shell.createUIContext(); try { return getForgeCommand(shellContext, name, completeLine); } catch (CommandNotFoundException cnfe) { // Not a forge command, fallback to aesh command CommandContainer<?> nativeCommand = aeshCommandRegistry.getCommand(name, completeLine); AeshUICommand aeshCommand = new AeshUICommand(nativeCommand); SingleCommandController controller = commandControllerFactory.createSingleController(shellContext, shell, aeshCommand); try { controller.initialize(); } catch (Exception e) { // Do nothing } ShellSingleCommand cmd = new ShellSingleCommand(controller, shellContext, commandLineUtil); CommandAdapter commandAdapter = new CommandAdapter(shell, shellContext, cmd); return new ForgeCommandContainer( shellContext, aeshCommand.getCommandLineParser(), commandAdapter); } }
private AbstractShellInteraction findCommand(ShellContext shellContext, String commandName) { AbstractShellInteraction result = null; UICommand cmd = commandFactory.getNewCommandByName(shellContext, commandName); if (cmd != null && cmd.isEnabled(shellContext)) { CommandController controller = commandControllerFactory.createController(shellContext, shell, cmd); if (controller instanceof WizardCommandController) { result = new ShellWizard( (WizardCommandController) controller, shellContext, commandLineUtil, this); } else { result = new ShellSingleCommand(controller, shellContext, commandLineUtil); } } return result; }