| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SvnCommandLineParser |
|
| 10.333333333333334;10.333 |
| 1 | /* | |
| 2 | StatCvs - CVS statistics generation | |
| 3 | Copyright (C) 2002 Lukasz Pekacki <lukasz@pekacki.de> | |
| 4 | http://statcvs.sf.net/ | |
| 5 | | |
| 6 | This library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with this library; if not, write to the Free Software | |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | | |
| 20 | $RCSfile: SvnCommandLineParser.java,v $ | |
| 21 | Created on $Date: 2005/03/20 19:12:25 $ | |
| 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 | 30 | 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 | 30 | super(args); |
| 53 | 30 | } |
| 54 | ||
| 55 | protected boolean doChildrenSwitch(final String switchName) throws ConfigurationException { | |
| 56 | 30 | final String s = switchName.toLowerCase(Locale.getDefault()); |
| 57 | 30 | if (s.equals("cache-dir")) { |
| 58 | 30 | if (isArgsEmpty()) { |
| 59 | 0 | throw new ConfigurationException("Missing argument for -cache-dir"); |
| 60 | } | |
| 61 | 30 | SvnConfigurationOptions.setCacheDir(popNextArg()); |
| 62 | 30 | 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("svnkit")) { |
| 93 | 0 | SvnConfigurationOptions.setUsingSvnKit(true); |
| 94 | 0 | } else if (s.equals("force-legacy-diff")) { |
| 95 | 0 | SvnConfigurationOptions.setLegacyDiff(true); |
| 96 | } else { | |
| 97 | 29 | return false; |
| 98 | } | |
| 99 | 1 | return true; |
| 100 | } | |
| 101 | ||
| 102 | /* | |
| 103 | * (non-Javadoc) | |
| 104 | * | |
| 105 | * @see net.sf.statcvs.output.CommandLineParser#checkForRequiredArgs() | |
| 106 | 29 | */ |
| 107 | 29 | protected void checkForRequiredArgs() throws ConfigurationException { |
| 108 | 1 | super.checkForRequiredArgs(); |
| 109 | 1 | if (!setCacheDir) { |
| 110 | 0 | SvnConfigurationOptions.setCacheDirToDefault(); |
| 111 | 29 | } |
| 112 | 29 | // now check if the user may have setup some WebIntegration that are not supported |
| 113 | 1 | final WebRepositoryIntegration integration = ConfigurationOptions.getWebRepository(); |
| 114 | 30 | if (integration instanceof ViewCvsIntegration && !(integration instanceof ViewVcIntegration)) { |
| 115 | 0 | throw new ConfigurationException("Sorry, ViewCvs is not supported by Subversion"); |
| 116 | 1 | } else if (integration instanceof CvswebIntegration) { |
| 117 | 29 | throw new ConfigurationException("Sorry, CvsWeb is not supported by Subversion"); |
| 118 | } | |
| 119 | 1 | } |
| 120 | } |