Package org.jboss.forge.shell.command

Examples of org.jboss.forge.shell.command.CommandMetadata


      Collection<CharSequence> colorizedCandidates = new ArrayList<CharSequence>();
      for (CharSequence seq : candidates)
      {
         boolean processed = false;
         CommandMetadata command = commandHolder.getState().getCommand();
         if ((command != null) && seq.toString().startsWith("--"))
         {
            String str = seq.toString().trim();
            if (str.startsWith("--"))
            {
               str = str.substring(2);
            }

            if (command.hasOption(str) && command.getNamedOption(str).isRequired())
            {
               seq = shell.renderColor(ShellColor.BLUE, seq.toString());
               colorizedCandidates.add(seq);
               processed = true;
            }
View Full Code Here


   @Override
   public void complete(final CommandCompleterState st)
   {
      PluginCommandCompleterState state = ((PluginCommandCompleterState) st);

      CommandMetadata command = state.getCommand();
      if (command != null)
      {
         if (command.hasOptions())
         {
            getOptionCandidates(command, state);
         }
      }
   }
View Full Code Here

            // there must be a command, or a string of arguments for the
            // default command
            String peek = tokens.peek();
            if (plugin.hasCommand(peek, shell))
            {
               CommandMetadata command = plugin.getCommand(tokens.remove());
               state.setCommand(command);

               // TODO this should probably be tokenComplete`?` sensitive
               // complete the command, remove the last token
            }
            else if (plugin.hasDefaultCommand())
            {
               CommandMetadata defaultCommand = plugin.getDefaultCommand();
               state.setCommand(defaultCommand);

            }
            else
            {
               // bad input, not a command and there is no default command
            }
         }
         else if (!tokens.isEmpty())
         {
            // just one more token, it's either a command or an argument
            // for the default command
            String peek = tokens.peek();
            if (plugin.hasCommand(peek, shell))
            {
               CommandMetadata command = plugin.getCommand(tokens.remove());
               state.setCommand(command);
            }
            else if (couldBeCommand(plugin, peek))
            {
               state.setIndex(state.getBuffer().lastIndexOf(peek));
               addCommandCandidates(plugin, state);
            }
         }
         else if (plugin.hasCommands())
         {
            addCommandCandidates(plugin, state);
         }

         if (plugin.hasDefaultCommand())
         {
            if ((state.getCommand() == null))
            {
               CommandMetadata defaultCommand = plugin.getDefaultCommand();
               state.setCommand(defaultCommand);
            }
            if (tokens.isEmpty() && !state.hasSuggestions() && plugin.getDefaultCommand().equals(state.getCommand()))
            {
               if (plugin.hasCommands())
View Full Code Here

   @Override
   public void complete(final CommandCompleterState st)
   {
      PluginCommandCompleterState state = ((PluginCommandCompleterState) st);

      CommandMetadata command = state.getCommand();
      if (command != null)
      {
         if (command.hasOptions())
         {
            getOptionCandidates(command, state);
         }
      }
   }
View Full Code Here

      for (List<PluginMetadata> list : registry.getPlugins().values())
      {
         for (PluginMetadata p : list)
         {
            CommandMetadata command = p.getCommand("setup", shell);
            if ((command != null) && !results.contains(p.getName()))
            {
               results.add(p.getName());
            }
         }
View Full Code Here

            }

            out.println();
            if (p.hasCommand(command, shell))
            {
               CommandMetadata c = p.getCommand(command);
               out.print(ShellColor.BOLD, "[" + p.getName() + " " + c.getName() + "] ");
               out.println("- "
                        + (!Strings.isNullOrEmpty(c.getHelp()) ? c.getHelp() : out.renderColor(ShellColor.ITALIC,
                                 NO_HELP)));

               printOptions(out, c);
            }
            else
View Full Code Here

         out.println(p.getResourceScopes().toString());
      }

      if (p.hasDefaultCommand())
      {
         CommandMetadata def = p.getDefaultCommand();
         if (def.hasOptions())
            printOptions(out, def);
      }

      List<CommandMetadata> commands = p.getCommands();
      if (commands.size() > 1)
View Full Code Here

      for (CharSequence seq : candidates)
      {
         boolean processed = false;
         if (commandHolder.getState() != null)
         {
            CommandMetadata command = commandHolder.getState().getCommand();
            if ((command != null) && seq.toString().startsWith("--"))
            {
               String str = seq.toString().trim();
               if (str.startsWith("--"))
               {
                  str = str.substring(2);
               }

               if (command.hasOption(str) && command.getNamedOption(str).isRequired())
               {
                  seq = shell.renderColor(ShellColor.BLUE, seq.toString());
                  colorizedCandidates.add(seq);
                  processed = true;
               }
View Full Code Here

            }

            out.println();
            if (p.hasCommand(command, shell))
            {
               CommandMetadata c = p.getCommand(command);
               out.print(ShellColor.BOLD, "[" + p.getName() + " " + c.getName() + "] ");
               out.println("- "
                        + (!Strings.isNullOrEmpty(c.getHelp()) ? c.getHelp() : out.renderColor(ShellColor.ITALIC,
                                 NO_HELP)));

               printOptions(out, c);
            }
            else
View Full Code Here

         out.println(p.getResourceScopes().toString());
      }

      if (p.hasDefaultCommand())
      {
         CommandMetadata def = p.getDefaultCommand();
         if (def.hasOptions())
            printOptions(out, def);
      }

      List<CommandMetadata> commands = p.getCommands();
      if (commands.size() > 1)
View Full Code Here

TOP

Related Classes of org.jboss.forge.shell.command.CommandMetadata

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.