| 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 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public class SvnCommandLineParser extends CommandLineParser { |
| 43 | 4 | private boolean setCacheDir = false; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public SvnCommandLineParser(final String[] args) { |
| 52 | 4 | super(args); |
| 53 | 4 | } |
| 54 | |
|
| 55 | |
protected boolean doChildrenSwitch(final String switchName) throws ConfigurationException { |
| 56 | 4 | final String s = switchName.toLowerCase(Locale.getDefault()); |
| 57 | 4 | if (s.equals("cache-dir")) { |
| 58 | 4 | if (isArgsEmpty()) { |
| 59 | 0 | throw new ConfigurationException("Missing argument for -cache-dir"); |
| 60 | |
} |
| 61 | 4 | SvnConfigurationOptions.setCacheDir(popNextArg()); |
| 62 | 4 | setCacheDir = true; |
| 63 | 0 | } else if (s.equals("username")) { |
| 64 | 0 | if (isArgsEmpty()) { |
| 65 | 0 | throw new ConfigurationException("Missing argument for -username"); |
| 66 | |
} |
| 67 | 0 | SvnConfigurationOptions.setSvnUsername(popNextArg()); |
| 68 | 0 | } else if (s.equals("password")) { |
| 69 | 0 | if (isArgsEmpty()) { |
| 70 | 0 | throw new ConfigurationException("Missing argument for -password"); |
| 71 | |
} |
| 72 | 0 | SvnConfigurationOptions.setSvnPassword(popNextArg()); |
| 73 | 0 | } else if (s.equals("threads")) { |
| 74 | 0 | if (isArgsEmpty()) { |
| 75 | 0 | throw new ConfigurationException("Missing argument for -threads"); |
| 76 | |
} |
| 77 | 0 | SvnConfigurationOptions.setNumberSvnDiffThreads(Integer.parseInt(popNextArg())); |
| 78 | 0 | } else if (s.equals("concurrency-threshold")) { |
| 79 | 0 | if (isArgsEmpty()) { |
| 80 | 0 | throw new ConfigurationException("Missing argument for -concurrency-threshold"); |
| 81 | |
} |
| 82 | 0 | SvnConfigurationOptions.setThresholdInMsToUseConcurrency(Integer.parseInt(popNextArg())); |
| 83 | 0 | } else if (s.equals("tags-dir")) { |
| 84 | 0 | if (isArgsEmpty()) { |
| 85 | 0 | throw new ConfigurationException("Missing argument for -tags-dir"); |
| 86 | |
} |
| 87 | 0 | SvnConfigurationOptions.setTagsDirectory(popNextArg()); |
| 88 | 0 | } else if (s.equals("dump")) { |
| 89 | 0 | SvnConfigurationOptions.setDumpContent(true); |
| 90 | 0 | } else if (s.equals("anonymize")) { |
| 91 | 0 | SvnConfigurationOptions.setAnonymize(true); |
| 92 | 0 | } else if (s.equals("force-legacy-diff")) { |
| 93 | 0 | SvnConfigurationOptions.setLegacyDiff(true); |
| 94 | |
} else { |
| 95 | 0 | return false; |
| 96 | |
} |
| 97 | 4 | return true; |
| 98 | |
} |
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
protected void checkForRequiredArgs() throws ConfigurationException { |
| 106 | 4 | super.checkForRequiredArgs(); |
| 107 | 4 | if (!setCacheDir) { |
| 108 | 0 | SvnConfigurationOptions.setCacheDirToDefault(); |
| 109 | |
} |
| 110 | |
|
| 111 | 4 | final WebRepositoryIntegration integration = ConfigurationOptions.getWebRepository(); |
| 112 | 4 | if (integration instanceof ViewCvsIntegration && !(integration instanceof ViewVcIntegration)) { |
| 113 | 0 | throw new ConfigurationException("Sorry, ViewCvs is not supported by Subversion"); |
| 114 | 4 | } else if (integration instanceof CvswebIntegration) { |
| 115 | 0 | throw new ConfigurationException("Sorry, CvsWeb is not supported by Subversion"); |
| 116 | |
} |
| 117 | 4 | } |
| 118 | |
} |