1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statsvn.output;
24
25 import java.util.Locale;
26
27 import net.sf.statcvs.output.CommandLineParser;
28 import net.sf.statcvs.output.ConfigurationException;
29 import net.sf.statcvs.output.ConfigurationOptions;
30 import net.sf.statcvs.output.CvswebIntegration;
31 import net.sf.statcvs.output.ViewCvsIntegration;
32 import net.sf.statcvs.output.ViewVcIntegration;
33 import net.sf.statcvs.output.WebRepositoryIntegration;
34
35 /**
36 * Takes a command line, like given to the {@link net.sf.statsvn.Main#main}
37 * method, and turns it into a {@link ConfigurationOptions} object.
38 *
39 * @author Richard Cyganiak <rcyg@gmx.de>
40 * @version $Id: SvnCommandLineParser.java,v 1.16 2005/03/20 19:12:25 squig Exp $
41 */
42 public class SvnCommandLineParser extends CommandLineParser {
43 private boolean setCacheDir = false;
44
45 /**
46 * Constructor for SvnCommandLineParser
47 *
48 * @param args
49 * the command line parameters
50 */
51 public SvnCommandLineParser(final String[] args) {
52 super(args);
53 }
54
55 protected boolean doChildrenSwitch(final String switchName) throws ConfigurationException {
56 final String s = switchName.toLowerCase(Locale.getDefault());
57 if (s.equals("cache-dir")) {
58 if (isArgsEmpty()) {
59 throw new ConfigurationException("Missing argument for -cache-dir");
60 }
61 SvnConfigurationOptions.setCacheDir(popNextArg());
62 setCacheDir = true;
63 } else if (s.equals("username")) {
64 if (isArgsEmpty()) {
65 throw new ConfigurationException("Missing argument for -username");
66 }
67 SvnConfigurationOptions.setSvnUsername(popNextArg());
68 } else if (s.equals("password")) {
69 if (isArgsEmpty()) {
70 throw new ConfigurationException("Missing argument for -password");
71 }
72 SvnConfigurationOptions.setSvnPassword(popNextArg());
73 } else if (s.equals("threads")) {
74 if (isArgsEmpty()) {
75 throw new ConfigurationException("Missing argument for -threads");
76 }
77 SvnConfigurationOptions.setNumberSvnDiffThreads(Integer.parseInt(popNextArg()));
78 } else if (s.equals("concurrency-threshold")) {
79 if (isArgsEmpty()) {
80 throw new ConfigurationException("Missing argument for -concurrency-threshold");
81 }
82 SvnConfigurationOptions.setThresholdInMsToUseConcurrency(Integer.parseInt(popNextArg()));
83 } else if (s.equals("tags-dir")) {
84 if (isArgsEmpty()) {
85 throw new ConfigurationException("Missing argument for -tags-dir");
86 }
87 SvnConfigurationOptions.setTagsDirectory(popNextArg());
88 } else if (s.equals("dump")) {
89 SvnConfigurationOptions.setDumpContent(true);
90 } else if (s.equals("anonymize")) {
91 SvnConfigurationOptions.setAnonymize(true);
92 } else if (s.equals("svnkit")) {
93 SvnConfigurationOptions.setUsingSvnKit(true);
94 } else if (s.equals("force-legacy-diff")) {
95 SvnConfigurationOptions.setLegacyDiff(true);
96 } else {
97 return false;
98 }
99 return true;
100 }
101
102
103
104
105
106
107 protected void checkForRequiredArgs() throws ConfigurationException {
108 super.checkForRequiredArgs();
109 if (!setCacheDir) {
110 SvnConfigurationOptions.setCacheDirToDefault();
111 }
112
113 final WebRepositoryIntegration integration = ConfigurationOptions.getWebRepository();
114 if (integration instanceof ViewCvsIntegration && !(integration instanceof ViewVcIntegration)) {
115 throw new ConfigurationException("Sorry, ViewCvs is not supported by Subversion");
116 } else if (integration instanceof CvswebIntegration) {
117 throw new ConfigurationException("Sorry, CvsWeb is not supported by Subversion");
118 }
119 }
120 }