@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 Set<String> getForgeCommandNames() { try (ShellContextImpl newShellContext = shell.createUIContext()) { return commandFactory.getEnabledCommandNames(newShellContext); } }