accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1396297 - /accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
Date Tue, 09 Oct 2012 20:30:57 GMT
Author: kturner
Date: Tue Oct  9 20:30:56 2012
New Revision: 1396297

URL: http://svn.apache.org/viewvc?rev=1396297&view=rev
Log:
ACCUMULO-703 made rfile-info command print usage

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java?rev=1396297&r1=1396296&r2=1396297&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java Tue
Oct  9 20:30:56 2012
@@ -28,8 +28,10 @@ import org.apache.accumulo.core.file.blo
 import org.apache.accumulo.core.file.rfile.RFile.Reader;
 import org.apache.commons.cli.BasicParser;
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -47,7 +49,20 @@ public class PrintInfo {
     Option histogramOption = new Option("h", "histogram", false, "print a histogram of the
key-value sizes");
     opts.addOption(histogramOption);
     
-    CommandLine commandLine = new BasicParser().parse(opts, args);
+    CommandLine commandLine = null;
+    try {
+      commandLine = new BasicParser().parse(opts, args);
+      if (commandLine.getArgs().length == 0) {
+        throw new ParseException("No files were given");
+      }
+      
+    } catch (ParseException e) {
+      System.err.println("Failed to parse command line : " + e.getMessage());
+      System.err.println();
+      HelpFormatter formatter = new HelpFormatter();
+      formatter.printHelp("rfile-info <rfile> {<rfile>}", opts);
+      System.exit(-1);
+    }
     
     boolean dump = commandLine.hasOption(dumpKeys.getOpt());
     boolean doHistogram = commandLine.hasOption(histogramOption.getOpt());



Mime
View raw message