01: /*****************************************************************************
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common
08: * Development and Distribution License("CDDL") (collectively, the
09: * "License"). You may not use this file except in compliance with the
10: * License. You can obtain a copy of the License at
11: * http://www.netbeans.org/cddl-gplv2.html
12: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13: * specific language governing permissions and limitations under the
14: * License. When distributing the software, include this License Header
15: * Notice in each file and include the License file at
16: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17: * particular file as subject to the "Classpath" exception as provided
18: * by Sun in the GPL Version 2 section of the License file that
19: * accompanied this code. If applicable, add the following below the
20: * License Header, with the fields enclosed by brackets [] replaced by
21: * your own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Contributor(s):
25:
26: * The Original Software is the CVS Client Library.
27: * The Initial Developer of the Original Software is Robert Greig.
28: * Portions created by Robert Greig are Copyright (C) 2000.
29: * All Rights Reserved.
30: *
31: * If you wish your version of this file to be governed by only the CDDL
32: * or only the GPL Version 2, indicate your decision by adding
33: * "[Contributor] elects to include this software in this distribution
34: * under the [CDDL or GPL Version 2] license." If you do not indicate a
35: * single choice of license, a recipient has the option to distribute
36: * your version of this file under either the CDDL, the GPL Version 2 or
37: * to extend the choice of license to its licensees as provided above.
38: * However, if you add GPL Version 2 code and therefore, elected the GPL
39: * Version 2 license, then the option applies only if the new code is
40: * made subject to such option by the copyright holder.
41:
42: * Contributor(s): Robert Greig.
43: *****************************************************************************/package org.netbeans.lib.cvsclient.commandLine.command;
44:
45: import java.io.*;
46:
47: import org.netbeans.lib.cvsclient.command.*;
48: import org.netbeans.lib.cvsclient.command.log.*;
49: import org.netbeans.lib.cvsclient.commandLine.*;
50:
51: /**
52: * The log command
53: * @author Robert Greig
54: */
55: public class log extends AbstractCommandProvider {
56:
57: public String[] getSynonyms() {
58: // Not "rlog"! We have a special rlog command.
59: return new String[] { "lo" }; // NOI18N
60: }
61:
62: public Command createCommand(String[] args, int index,
63: GlobalOptions gopt, String workDir) {
64: LogCommand command = new LogCommand();
65: final String getOptString = command.getOptString();
66: GetOpt go = new GetOpt(args, getOptString);
67: int ch = -1;
68: go.optIndexSet(index);
69: boolean usagePrint = false;
70: String arg;
71: while ((ch = go.getopt()) != go.optEOF) {
72: boolean ok = command.setCVSCommand((char) ch, go
73: .optArgGet());
74: if (!ok) {
75: usagePrint = true;
76: }
77: }
78: if (usagePrint) {
79: throw new IllegalArgumentException(getUsage());
80: }
81: int fileArgsIndex = go.optIndexGet();
82: // test if we have been passed any file arguments
83: if (fileArgsIndex < args.length) {
84: File[] fileArgs = new File[args.length - fileArgsIndex];
85: // send the arguments as absolute paths
86: if (workDir == null) {
87: workDir = System.getProperty("user.dir");
88: }
89: File workingDir = new File(workDir);
90: for (int i = fileArgsIndex; i < args.length; i++) {
91: fileArgs[i - fileArgsIndex] = new File(workingDir,
92: args[i]);
93: }
94: command.setFiles(fileArgs);
95: }
96: return command;
97: }
98:
99: }
|