Revision: 7592
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7592&view=rev
Author:   dnaber
Date:     2012-06-30 17:55:17 +0000 (Sat, 30 Jun 2012)
Log Message:
-----------
new option "--version" for command line use: print version number and exit

Modified Paths:
--------------
    trunk/JLanguageTool/src/java/org/languagetool/Main.java
    
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineOptions.java
    
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineParser.java
    
trunk/JLanguageTool/src/test/org/languagetool/commandline/CommandLineParserTest.java

Modified: trunk/JLanguageTool/src/java/org/languagetool/Main.java
===================================================================
--- trunk/JLanguageTool/src/java/org/languagetool/Main.java     2012-06-30 
17:54:58 UTC (rev 7591)
+++ trunk/JLanguageTool/src/java/org/languagetool/Main.java     2012-06-30 
17:55:17 UTC (rev 7592)
@@ -451,6 +451,10 @@
       commandLineParser.printUsage();
       System.exit(1);
     }
+    if (options.isPrintVersion()) {
+      System.out.println("LanguageTool version " + JLanguageTool.VERSION);
+      System.exit(0);
+    }
 
     if (options.getFilename() == null) {
       options.setFilename("-");

Modified: 
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineOptions.java
===================================================================
--- 
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineOptions.java
   2012-06-30 17:54:58 UTC (rev 7591)
+++ 
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineOptions.java
   2012-06-30 17:55:17 UTC (rev 7592)
@@ -25,6 +25,7 @@
  */
 public class CommandLineOptions {
 
+  private boolean printVersion = false;
   private boolean verbose = false;
   private boolean recursive = false;
   private boolean taggerOnly = false;
@@ -42,6 +43,14 @@
   private String[] disabledRules = new String[0];
   private String[] enabledRules = new String[0];
 
+  public boolean isPrintVersion() {
+    return printVersion;
+  }
+
+  public void setPrintVersion(boolean printVersion) {
+    this.printVersion = printVersion;
+  }
+
   public boolean isVerbose() {
     return verbose;
   }
@@ -169,4 +178,5 @@
   public void setEnabledRules(String[] enabledRules) {
     this.enabledRules = enabledRules;
   }
+
 }

Modified: 
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineParser.java
===================================================================
--- 
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineParser.java
    2012-06-30 17:54:58 UTC (rev 7591)
+++ 
trunk/JLanguageTool/src/java/org/languagetool/commandline/CommandLineParser.java
    2012-06-30 17:55:17 UTC (rev 7592)
@@ -35,7 +35,9 @@
     }
     final CommandLineOptions options = new CommandLineOptions();
     for (int i = 0; i < args.length; i++) {
-      if (args[i].equals("-h") || args[i].equals("-help") || 
args[i].equals("--help") || args[i].equals("--?")) {
+      if (args[i].equals("--version")) {
+        options.setPrintVersion(true);
+      } else if (args[i].equals("-h") || args[i].equals("-help") || 
args[i].equals("--help") || args[i].equals("--?")) {
         throw new IllegalArgumentException();
       } else if (args[i].equals("-adl") || args[i].equals("--autoDetect")) {   
 // set autoDetect flag
         // also initialize the other language profiles for the 
LanguageIdentifier
@@ -137,6 +139,7 @@
             + "  --api                    print results as XML\n"
             + "  -p, --profile            print performance measurements\n"
             + "  -v, --verbose            print text analysis (sentences, 
part-of-speech tags) to STDERR\n"
+            + "  --version                print LanguageTool version number 
and exit\n"
             + "  -a, --apply              automatically apply suggestions if 
available, printing result to STDOUT");
   }
 

Modified: 
trunk/JLanguageTool/src/test/org/languagetool/commandline/CommandLineParserTest.java
===================================================================
--- 
trunk/JLanguageTool/src/test/org/languagetool/commandline/CommandLineParserTest.java
        2012-06-30 17:54:58 UTC (rev 7591)
+++ 
trunk/JLanguageTool/src/test/org/languagetool/commandline/CommandLineParserTest.java
        2012-06-30 17:55:17 UTC (rev 7592)
@@ -68,6 +68,9 @@
     assertEquals(Language.GERMAN, options.getLanguage());
     assertEquals("filename.txt", options.getFilename());
     assertTrue(options.isVerbose());
+
+    options = parser.parseOptions(new String[]{"--version"});
+    assertTrue(options.isPrintVersion());
   }
 
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to