Wrote a usage message for the CommandLineRunner.
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 28 May 2009 18:59:11 +0000 (18:59 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 28 May 2009 18:59:11 +0000 (18:59 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@962 59b500cc-1b3d-0410-9834-0bbf25fbcc57

javase/src/com/google/zxing/client/j2se/CommandLineRunner.java

index a09bdf6..ea09f34 100644 (file)
@@ -55,6 +55,10 @@ public final class CommandLineRunner {
   }
 
   public static void main(String[] args) throws Exception {
+    if (args == null || args.length == 0) {
+      printUsage();
+      return;
+    }
     Hashtable<DecodeHintType, Object> hints = null;
     boolean dumpResults = false;
     boolean dumpBlackPoint = false;
@@ -66,8 +70,9 @@ public final class CommandLineRunner {
         dumpResults = true;
       } else if ("--dump_black_point".equals(arg)) {
         dumpBlackPoint = true;
-      } else if (arg.startsWith("--")) {
+      } else if (arg.startsWith("-")) {
         System.out.println("Unknown command line option " + arg);
+        printUsage();
         return;
       }
     }
@@ -78,6 +83,14 @@ public final class CommandLineRunner {
     }
   }
 
+  private static void printUsage() {
+    System.out.println("Decode barcode images using the ZXing library\n");
+    System.out.println("usage: CommandLineRunner { file | dir | url } [ options ]");
+    System.out.println("  --try_harder: Use the TRY_HARDER hint, default is normal (mobile) mode");
+    System.out.println("  --dump_results: Write the decoded contents to input.txt");
+    System.out.println("  --dump_black_point: Compare black point algorithms as input.mono.png");
+  }
+
   private static void decodeOneArgument(String argument, Hashtable<DecodeHintType, Object> hints,
       boolean dumpResults, boolean dumpBlackPoint) throws IOException,
       URISyntaxException {