Package org.jboss.forge.addon.shell.aesh

Examples of org.jboss.forge.addon.shell.aesh.AbstractShellInteraction


      return commands;
   }

   public AbstractShellInteraction findCommand(ShellContext shellContext, String commandName)
   {
      AbstractShellInteraction result = null;
      CommandLineUtil cmdLineUtil = getCommandLineUtil();
      for (UICommand cmd : Commands.getEnabledCommands(getAllCommands(), shellContext))
      {
         if (commandName.equals(getCommandName(shellContext, cmd)))
         {
View Full Code Here


      return commands;
   }

   public AbstractShellInteraction findCommand(ShellContext shellContext, String commandName)
   {
      AbstractShellInteraction result = null;
      CommandLineUtil cmdLineUtil = getCommandLineUtil();
      for (UICommand cmd : Commands.getEnabledCommands(getAllCommands(), shellContext))
      {
         if (commandName.equals(getCommandName(shellContext, cmd)))
         {
View Full Code Here

   {
      Map<String, AbstractShellInteraction> commands = new HashMap<String, AbstractShellInteraction>();
      CommandLineUtil cmdLineUtil = getCommandLineUtil();
      for (UICommand cmd : Commands.getEnabledCommands(getAllCommands(), shellContext))
      {
         AbstractShellInteraction shellCommand;
         if (cmd instanceof UIWizard)
         {
            shellCommand = new ShellWizard((UIWizard) cmd, shellContext, cmdLineUtil, this);
         }
         else
         {
            shellCommand = new ShellSingleCommand(cmd, shellContext, cmdLineUtil);
         }
         commands.put(shellCommand.getName(), shellCommand);
      }
      return commands;
   }
View Full Code Here

   @Override
   public void complete(CompleteOperation completeOperation)
   {
      String line = completeOperation.getBuffer();
      ShellContext shellContext = shell.newShellContext();
      final AbstractShellInteraction cmd = shell.findCommand(shellContext, line);
      if (cmd == null)
      {
         Collection<AbstractShellInteraction> commands = shell.findMatchingCommands(shellContext, line);
         for (AbstractShellInteraction command : commands)
         {
            completeOperation.addCompletionCandidate(command.getName());
         }
      }
      else if (line.equals(cmd.getName()))
      {
         completeOperation.addCompletionCandidate(" ");
      }
      else
      {
         try
         {
            // We are dealing with one-level commands only.
            // Eg. new-project-type --named ... instead of new-project-type setup --named ...
            // cmd.populateInputs(line, true);
            ParsedCompleteObject completeObject = cmd.parseCompleteObject(line);
            if (completeObject.doDisplayOptions())
            {
               List<String> options = cmd.getCompletionOptions(completeObject.getName(), line);
               completeOperation.addCompletionCandidates(options);
               if (completeOperation.getCompletionCandidates().size() == 1)
               {
                  completeOperation.setOffset(completeOperation.getCursor() - completeObject.getOffset());
               }
            }
            else
            {
               final InputComponent<?, Object> input;
               if (completeObject.isOption())
               {
                  // try to complete an option value. Eg: "--xxx"
                  input = cmd.getInputs().get(completeObject.getName());
               }
               // try to complete a argument value Eg: ls . (. is the argument)
               else if (completeObject.isArgument())
               {
                  input = cmd.getInputs().get(ARGUMENTS_INPUT_NAME); // default for arguments
               }
               else
               {
                  input = null;
               }
               if (input != null)
               {
                  CompletionStrategy completionObj = CompletionStrategyFactory.getCompletionFor(input);
                  completionObj.complete(completeOperation, input, shellContext, completeObject.getValue(),
                           shell.getConverterFactory());
               }
            }
         }
         catch (ArgumentParserException e)
         {
            if (!cmd.getInputs().isEmpty())
            {
               completeOperation.doAppendSeparator(false);
               completeOperation.addCompletionCandidate(line + "--");
            }
         }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.shell.aesh.AbstractShellInteraction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.