Package org.jboss.forge.shell.command

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


      if (state.getPlugin() != null)
      {
         Queue<String> tokens = state.getTokens();

         state.setIndex(state.getBuffer().length());
         PluginMetadata plugin = state.getPlugin();
         if (tokens.size() > 1)
         {
            // 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())
               {
                  addCommandCandidates(plugin, state);
               }
            }
         }
View Full Code Here


      Queue<String> tokens = state.getTokens();

      if (!tokens.isEmpty())
      {
         String pluginName = tokens.remove();
         PluginMetadata plugin = registry.getPluginMetadataForScopeAndConstraints(pluginName, shell);

         if ((plugin != null))
         {
            // found a plugin match directly
            state.setPlugin(plugin);
View Full Code Here

                  printPlugin(out, p, all);
               }
            }
            else
            {
               PluginMetadata p = registry.getPluginMetadataForScopeAndConstraints(plugin, shell);
               if (p == null)
               {
                  p = list.get(0);
               }
               printPlugin(out, p, all);
            }
         }

         if (!Strings.isNullOrEmpty(command))
         {
            PluginMetadata p = registry.getPluginMetadataForScopeAndConstraints(plugin, shell);
            if (p == null)
            {
               p = list.get(0);
            }

            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);
View Full Code Here

                  printPlugin(out, p, all);
               }
            }
            else
            {
               PluginMetadata p = registry.getPluginMetadataForScopeAndConstraints(plugin, shell);
               if (p == null)
               {
                  p = list.get(0);
               }
               printPlugin(out, p, all);
            }
         }

         if (!Strings.isNullOrEmpty(command))
         {
            PluginMetadata p = registry.getPluginMetadataForScopeAndConstraints(plugin, shell);
            if (p == null)
            {
               p = list.get(0);
            }

            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);
View Full Code Here

      Queue<String> tokens = state.getTokens();

      if (!tokens.isEmpty())
      {
         String pluginName = tokens.remove();
         PluginMetadata plugin = registry.getPluginMetadataForScopeAndConstraints(pluginName, shell);

         if ((plugin != null))
         {
            // found a plugin match directly
            state.setPlugin(plugin);
View Full Code Here

      if (state.getPlugin() != null)
      {
         Queue<String> tokens = state.getTokens();

         state.setIndex(state.getBuffer().length());
         PluginMetadata plugin = state.getPlugin();
         if (tokens.size() > 1)
         {
            // 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())
               {
                  addCommandCandidates(plugin, state);
               }
            }
         }
View Full Code Here

      Queue<String> tokens = state.getTokens();

      if (!tokens.isEmpty())
      {
         String pluginName = tokens.remove();
         PluginMetadata plugin = registry.getPluginMetadataForScopeAndConstraints(pluginName, shell);

         if ((plugin != null))
         {
            // found a plugin match directly
            state.setPlugin(plugin);
View Full Code Here

                  printPlugin(out, p, all);
               }
            }
            else
            {
               PluginMetadata p = registry.getPluginMetadataForScopeAndConstraints(plugin, shell);
               if (p == null)
               {
                  p = list.get(0);
               }
               printPlugin(out, p, all);
            }
         }

         if (!Strings.isNullOrEmpty(command))
         {
            PluginMetadata p = registry.getPluginMetadataForScopeAndConstraints(plugin, shell);
            if (p == null)
            {
               p = list.get(0);
            }

            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);
View Full Code Here

      if (state.getPlugin() != null)
      {
         Queue<String> tokens = state.getTokens();

         state.setIndex(state.getBuffer().length());
         PluginMetadata plugin = state.getPlugin();
         if (tokens.size() > 1)
         {
            // 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())
               {
                  addCommandCandidates(plugin, state);
               }
            }
         }
View Full Code Here

TOP

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

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.