public Command createCommand(final String[] args, final int index, final GlobalOptions gopt, String workDir) {
        final CommitCommand command = new CommitCommand();
        command.setBuilder(null);
        final String getOptString = command.getOptString();
        final GetOpt go = new GetOpt(args, getOptString);
        int ch = -1;
        go.optIndexSet(index);
        boolean usagePrint = false;
        while ((ch = go.getopt()) != GetOpt.optEOF) {
            final boolean ok = command.setCVSCommand((char) ch, go.optArgGet());
            if (!ok) {
                usagePrint = true;
            }
        }
        if (usagePrint) {
            throw new IllegalArgumentException(getUsage());
        }

        final int fileArgsIndex = go.optIndexGet();

        File[] fileArgs = null;

        // test if we have been passed any file arguments
        if (fileArgsIndex < args.length) {
            fileArgs = new File[args.length - fileArgsIndex];
            // send the arguments as absolute paths
            if (workDir == null) {
                workDir = System.getProperty("user.dir");
            }
            final File workingDir = new File(workDir);
            for (int i = fileArgsIndex; i < args.length; i++) {
                fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]);
            }
            command.setFiles(fileArgs);
        }

        // now only bring up the editor if the message has not been set using
        // the -m option
        if ((command.getMessage() == null) && (command.getLogMessageFromFile() == null)) {
            final String message = createMessage(fileArgs, gopt);
            if (message == null) {
                throw new IllegalArgumentException(java.util.ResourceBundle.getBundle(
                                commit.class.getPackage().getName() + ".Bundle")
                                .getString("commit.messageNotSpecified"));
            }
            command.setMessage(message);
        }

        return command;
    }