Beispiel #1
0
 public void run() throws SVNException {
   if (!getEnvironment().getArguments().isEmpty()) {
     for (Iterator commands = getEnvironment().getArguments().iterator(); commands.hasNext(); ) {
       String commandName = (String) commands.next();
       AbstractSVNCommand command = AbstractSVNCommand.getCommand(commandName);
       if (command == null) {
         getEnvironment().getErr().println("\"" + commandName + "\": unknown command.\n");
         continue;
       }
       String help =
           SVNCommandUtil.getCommandHelp(command, getEnvironment().getProgramName(), true);
       getEnvironment().getOut().println(help);
     }
   } else if (getSVNLookEnvironment().isVersion()) {
     String version = SVNCommandUtil.getVersion(getEnvironment(), false);
     getEnvironment().getOut().println(version);
     getEnvironment().getOut().println(VERSION_HELP_FOOTER);
   } else if (getEnvironment().getArguments().isEmpty()) {
     String help =
         SVNCommandUtil.getGenericHelp(
             getEnvironment().getProgramName(), GENERIC_HELP_HEADER, null, null);
     getEnvironment().getOut().print(help);
   } else {
     String message =
         MessageFormat.format(
             "Type ''{0} help'' for usage.", new Object[] {getEnvironment().getProgramName()});
     getEnvironment().getOut().println(message);
   }
 }
  protected String refineCommandName(String commandName, SVNCommandLine commandLine)
      throws SVNException {
    for (Iterator options = commandLine.optionValues(); options.hasNext(); ) {
      SVNOptionValue optionValue = (SVNOptionValue) options.next();
      AbstractSVNOption option = optionValue.getOption();
      if (option == SVNDumpFilterOption.HELP || option == SVNDumpFilterOption.QUESTION) {
        myIsHelp = true;
      } else if (option == SVNDumpFilterOption.VERSION) {
        myIsVersion = true;
      }
    }

    if (myIsHelp) {
      List newArguments =
          commandName != null ? Collections.singletonList(commandName) : Collections.EMPTY_LIST;
      setArguments(newArguments);
      return "help";
    }
    if (commandName == null) {
      if (isVersion()) {
        SVNDumpFilterCommand versionCommand =
            new SVNDumpFilterCommand("--version", null, 0) {
              protected Collection createSupportedOptions() {
                LinkedList options = new LinkedList();
                options.add(SVNDumpFilterOption.VERSION);
                return options;
              }

              public void run() throws SVNException {
                AbstractSVNCommand helpCommand = AbstractSVNCommand.getCommand("help");
                helpCommand.init(SVNDumpFilterCommandEnvironment.this);
                helpCommand.run();
              }
            };
        AbstractSVNCommand.registerCommand(versionCommand);
        return "--version";
      }
      SVNErrorMessage err =
          SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS, "Subcommand argument required");
      SVNErrorManager.error(err, SVNLogType.CLIENT);
    }
    return commandName;
  }