Revision: 8332
http://languagetool.svn.sourceforge.net/languagetool/?rev=8332&view=rev
Author: dnaber
Date: 2012-11-10 00:08:07 +0000 (Sat, 10 Nov 2012)
Log Message:
-----------
show usage if LT is called without parameters at all
Modified Paths:
--------------
trunk/JLanguageTool/src/main/java/org/languagetool/Main.java
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/CommandLineParser.java
trunk/JLanguageTool/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
Added Paths:
-----------
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/WrongParameterNumberException.java
Modified: trunk/JLanguageTool/src/main/java/org/languagetool/Main.java
===================================================================
--- trunk/JLanguageTool/src/main/java/org/languagetool/Main.java
2012-11-09 20:46:48 UTC (rev 8331)
+++ trunk/JLanguageTool/src/main/java/org/languagetool/Main.java
2012-11-10 00:08:07 UTC (rev 8332)
@@ -38,6 +38,7 @@
import org.languagetool.commandline.CommandLineOptions;
import org.languagetool.commandline.CommandLineParser;
import org.languagetool.commandline.UnknownParameterException;
+import org.languagetool.commandline.WrongParameterNumberException;
import org.languagetool.rules.Rule;
import org.languagetool.rules.bitext.BitextRule;
import org.languagetool.tools.StringTools;
@@ -446,6 +447,9 @@
CommandLineOptions options = null;
try {
options = commandLineParser.parseOptions(args);
+ } catch (WrongParameterNumberException e) {
+ commandLineParser.printUsage();
+ System.exit(1);
} catch (IllegalArgumentException e) {
System.err.println(e.toString());
System.exit(1);
Modified:
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/CommandLineParser.java
===================================================================
---
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/CommandLineParser.java
2012-11-09 20:46:48 UTC (rev 8331)
+++
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/CommandLineParser.java
2012-11-10 00:08:07 UTC (rev 8332)
@@ -33,7 +33,7 @@
public CommandLineOptions parseOptions(String[] args) {
if (args.length < 1 || args.length > 10) {
- throw new IllegalArgumentException();
+ throw new WrongParameterNumberException();
}
final CommandLineOptions options = new CommandLineOptions();
for (int i = 0; i < args.length; i++) {
Added:
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/WrongParameterNumberException.java
===================================================================
---
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/WrongParameterNumberException.java
(rev 0)
+++
trunk/JLanguageTool/src/main/java/org/languagetool/commandline/WrongParameterNumberException.java
2012-11-10 00:08:07 UTC (rev 8332)
@@ -0,0 +1,25 @@
+/* LanguageTool, a natural language style checker
+ * Copyright (C) 2012 Daniel Naber (http://www.danielnaber.de)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+package org.languagetool.commandline;
+
+/**
+ * Thrown if too few or too many command line parameters are specified.
+ */
+public class WrongParameterNumberException extends RuntimeException {
+}
Modified:
trunk/JLanguageTool/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
===================================================================
---
trunk/JLanguageTool/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
2012-11-09 20:46:48 UTC (rev 8331)
+++
trunk/JLanguageTool/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
2012-11-10 00:08:07 UTC (rev 8332)
@@ -29,7 +29,7 @@
try {
parser.parseOptions(new String[]{});
fail();
- } catch (IllegalArgumentException expected) {}
+ } catch (WrongParameterNumberException expected) {}
final CommandLineOptions commandLineOptions = parser.parseOptions(new
String[]{"--help"});
assertTrue(commandLineOptions.isPrintUsage());
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits