aboutsummaryrefslogtreecommitdiffstats
path: root/src/Test.java
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-06-27 12:08:36 +0200
committerMattias Andrée <maandree@operamail.com>2013-06-27 12:08:36 +0200
commit8798451585f0e603abb8c8fe7d397efca3d1f175 (patch)
tree115686e558999373a3f82ce5441b08f21cae6c88 /src/Test.java
parentmessage should be null if there are no message arguments (diff)
downloadargparser-8798451585f0e603abb8c8fe7d397efca3d1f175.tar.gz
argparser-8798451585f0e603abb8c8fe7d397efca3d1f175.tar.bz2
argparser-8798451585f0e603abb8c8fe7d397efca3d1f175.tar.xz
add argument checking in java test
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/Test.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/Test.java b/src/Test.java
index e6c5a18..e7be3fd 100644
--- a/src/Test.java
+++ b/src/Test.java
@@ -50,7 +50,33 @@ public class Test
parser.parse(args);
parser.supportAlternatives();
- parser.help();
+ if (parser.opts.get("-?") != null)
+ parser.help();
+ else if ((parser.unrecognisedCount + parser.files.size() == 0) && (parser.arguments.length > 0))
+ {
+ if (parser.opts.get("--hello") != null)
+ { for (int i = 0, n = parser.opts.get("--hello").length; i < n; i++)
+ System.out.println("Hello World");
+ }
+ if (parser.opts.get("-l") != null)
+ { for (String line : parser.opts.get("--line"))
+ System.out.println(line);
+ }
+ if (parser.opts.get("--lines") != null)
+ { for (String line : parser.opts.get("--l"))
+ System.out.println(line);
+ }
+ if (parser.opts.get("++hidden") != null)
+ { System.out.println("Congratulations, you have found the secret option!");
+ }
+ }
+ else
+ { System.out.println("Number of unrecognised options: " + parser.unrecognisedCount);
+ System.out.println("Entered message: " + parser.message);
+ System.out.println("Entered files:");
+ for (String file : parser.files)
+ System.out.println("\t" + file);
+ }
}
}