Package org.codehaus.groovy.tools.shell

Examples of org.codehaus.groovy.tools.shell.Command


    // Figure out the max command name and shortcut length dynamically
    int maxName = 0;
    int maxShortcut = 0;
    iterator = shell.getRegistry().commands().iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }

      if (command.getName().length() > maxName) {
        maxName = command.getName().length();
      }
       
      if (command.getShortcut().length() > maxShortcut) {
        maxShortcut = command.getShortcut().length();
      }
    }

    printlnResource(Constants.RES_HELP_INFO);
    println();

    // List the commands we know about
    printlnResource(Constants.RES_HELP_AVAIL_COMMANDS);

    iterator = shell.getRegistry().commands().iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }

      String paddedName = StringUtils.rightPad(command.getName(), maxName);
      String paddedShortcut = StringUtils.rightPad(command.getShortcut(), maxShortcut);

      String description = command.getDescription();

      StringBuilder sb = new StringBuilder();
      sb.append("  ")
         .append(MessageFormat.format(resource.getString(Constants
             .RES_HELP_CMD_DESCRIPTION), paddedName,
View Full Code Here


    printlnResource(Constants.RES_HELP_SPECIFIC_CMD_INFO);
    println();
  }

  private void help(String name) {
    Command command = shell.getRegistry().find(name);
    if (command == null) {
      String msg = MessageFormat.format(resource.getString(Constants
          .RES_UNRECOGNIZED_CMD), name);
      throw new SqoopException(ShellError.SHELL_0001, msg);
    }
    printlnResource(Constants.RES_HELP_CMD_USAGE, command.getName(), command.getUsage());
    println();
    println(command.getHelp());
    println();
  }
View Full Code Here

  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected List createCompletors() {
    SimpleCompletor completor = new SimpleCompletor();
    Iterator<Command> iterator = registry.iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }
           
      completor.add(command.getName());
    }

    List completors = new LinkedList();
    completors.add(completor);
    return completors;
View Full Code Here

    CommandRegistry registry = shell.getRegistry();
    @SuppressWarnings("unchecked")
    Iterator<Command> iterator = registry.iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (!commandsToKeep.contains(command.getName())) {
        iterator.remove();
        // remove from "names" set to avoid duplicate error.
        registry.remove(command);
      }
    }
View Full Code Here

    // Figure out the max command name and shortcut length dynamically
    int maxName = 0;
    int maxShortcut = 0;
    iterator = shell.getRegistry().commands().iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }

      if (command.getName().length() > maxName) {
        maxName = command.getName().length();
      }
       
      if (command.getShortcut().length() > maxShortcut) {
        maxShortcut = command.getShortcut().length();
      }
    }
   
    io.out.println(clientResource.getString(Constants.RES_HELP_INFO));
    io.out.println();

    // List the commands we know about
    io.out.println(clientResource.getString(Constants.RES_HELP_AVAIL_COMMANDS));

    iterator = shell.getRegistry().commands().iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }

      String paddedName =
          StringUtils.rightPad(command.getName(), maxName);
      String paddedShortcut =
          StringUtils.rightPad(command.getShortcut(), maxShortcut);
       
      String description = command.getDescription();

      StringBuilder sb = new StringBuilder();
      sb.append("  ")
         .append(MessageFormat.format(clientResource.getString(Constants
             .RES_HELP_CMD_DESCRIPTION), paddedName,
View Full Code Here

    io.out.println(clientResource.getString(Constants.RES_HELP_SPECIFIC_CMD_INFO));
    io.out.println();
  }

  private void help(String name) {
    Command command = shell.getRegistry().find(name);
    if (command == null) {
      String msg = MessageFormat.format(clientResource.getString(Constants
          .RES_UNRECOGNIZED_CMD), name);
      throw new SqoopException(ClientError.CLIENT_0001, msg);
    }
    io.out.println(MessageFormat.format(clientResource.getString
        (Constants.RES_HELP_CMD_USAGE), command.getName(),
        command.getUsage()));
    io.out.println();
    io.out.println(command.getHelp());
    io.out.println();
  }
View Full Code Here

  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected List createCompletors() {
    SimpleCompletor completor = new SimpleCompletor();
    Iterator<Command> iterator = registry.iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }
           
      completor.add(command.getName());
    }

    List completors = new LinkedList();
    completors.add(completor);
    return completors;
View Full Code Here

    CommandRegistry registry = shell.getRegistry();
    @SuppressWarnings("unchecked")
    Iterator<Command> iterator = registry.iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (!commandsToKeep.contains(command.getName())) {
        iterator.remove();
        // remove from "names" set to avoid duplicate error.
        registry.remove(command);
      }
    }
View Full Code Here

    // Figure out the max command name and shortcut length dynamically
    int maxName = 0;
    int maxShortcut = 0;
    iterator = shell.getRegistry().commands().iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }

      if (command.getName().length() > maxName) {
        maxName = command.getName().length();
      }
       
      if (command.getShortcut().length() > maxShortcut) {
        maxShortcut = command.getShortcut().length();
      }
    }

    printlnResource(Constants.RES_HELP_INFO);
    println();

    // List the commands we know about
    printlnResource(Constants.RES_HELP_AVAIL_COMMANDS);

    iterator = shell.getRegistry().commands().iterator();
    while (iterator.hasNext()) {
      Command command = iterator.next();
      if (command.getHidden()) {
        continue;
      }

      String paddedName = StringUtils.rightPad(command.getName(), maxName);
      String paddedShortcut = StringUtils.rightPad(command.getShortcut(), maxShortcut);

      String description = command.getDescription();

      StringBuilder sb = new StringBuilder();
      sb.append("  ")
         .append(MessageFormat.format(resource.getString(Constants
             .RES_HELP_CMD_DESCRIPTION), paddedName,
View Full Code Here

    printlnResource(Constants.RES_HELP_SPECIFIC_CMD_INFO);
    println();
  }

  private void help(String name) {
    Command command = shell.getRegistry().find(name);
    if (command == null) {
      String msg = MessageFormat.format(resource.getString(Constants
          .RES_UNRECOGNIZED_CMD), name);
      throw new SqoopException(ClientError.CLIENT_0001, msg);
    }
    printlnResource(Constants.RES_HELP_CMD_USAGE, command.getName(), command.getUsage());
    println();
    println(command.getHelp());
    println();
  }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.tools.shell.Command

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.