Ejemplo n.º 1
0
 public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) {
   RemoveCommand command = new RemoveCommand();
   command.setBuilder(null);
   final String getOptString = command.getOptString();
   GetOpt go = new GetOpt(args, getOptString);
   int ch = -1;
   go.optIndexSet(index);
   boolean usagePrint = false;
   while ((ch = go.getopt()) != go.optEOF) {
     boolean ok = command.setCVSCommand((char) ch, go.optArgGet());
     if (!ok) {
       usagePrint = true;
     }
   }
   if (usagePrint) {
     throw new IllegalArgumentException(getUsage());
   }
   int fileArgsIndex = go.optIndexGet();
   // test if we have been passed any file arguments
   if (fileArgsIndex < args.length) {
     File[] fileArgs = new File[args.length - fileArgsIndex];
     // send the arguments as absolute paths
     if (workDir == null) {
       workDir = System.getProperty("user.dir");
     }
     File workingDir = new File(workDir);
     for (int i = fileArgsIndex; i < args.length; i++) {
       fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]);
     }
     command.setFiles(fileArgs);
   }
   return command;
 }