mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r996296 - in /mahout/trunk/core/src/main/java/org/apache/mahout/common: AbstractJob.java CommandLineUtil.java
Date Sun, 12 Sep 2010 11:39:54 GMT
Author: gsingers
Date: Sun Sep 12 11:39:54 2010
New Revision: 996296

URL: http://svn.apache.org/viewvc?rev=996296&view=rev
Log:
provide some more information for when command lines are off

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/common/AbstractJob.java
    mahout/trunk/core/src/main/java/org/apache/mahout/common/CommandLineUtil.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/common/AbstractJob.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/common/AbstractJob.java?rev=996296&r1=996295&r2=996296&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/common/AbstractJob.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/common/AbstractJob.java Sun Sep 12 11:39:54
2010
@@ -263,7 +263,7 @@ public abstract class AbstractJob extend
 
     } catch (OptionException e) {
       log.error(e.getMessage());
-      CommandLineUtil.printHelpWithGenericOptions(group);
+      CommandLineUtil.printHelpWithGenericOptions(group, e);
       return null;
     }
 

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/common/CommandLineUtil.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/common/CommandLineUtil.java?rev=996296&r1=996295&r2=996296&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/common/CommandLineUtil.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/common/CommandLineUtil.java Sun Sep
12 11:39:54 2010
@@ -20,6 +20,7 @@ package org.apache.mahout.common;
 import java.io.PrintWriter;
 
 import org.apache.commons.cli2.Group;
+import org.apache.commons.cli2.OptionException;
 import org.apache.commons.cli2.util.HelpFormatter;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.util.GenericOptionsParser;
@@ -56,4 +57,20 @@ public final class CommandLineUtil {
     pw.flush();
   }
 
+  public static void printHelpWithGenericOptions(Group group, OptionException oe) {
+    org.apache.commons.cli.Options ops = new org.apache.commons.cli.Options();
+    new GenericOptionsParser(new Configuration(), ops, new String[0]);
+    org.apache.commons.cli.HelpFormatter fmt = new org.apache.commons.cli.HelpFormatter();
+    fmt.printHelp("<command> [Generic Options] [Job-Specific Options]",
+        "Generic Options:", ops, "");
+
+    PrintWriter pw = new PrintWriter(System.out);
+    HelpFormatter formatter = new HelpFormatter();
+    formatter.setGroup(group);
+    formatter.setPrintWriter(pw);
+    formatter.setException(oe);
+    formatter.printHelp();
+    pw.flush();
+  }
+
 }



Mime
View raw message