aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java')
-rw-r--r--third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java
new file mode 100644
index 0000000000..44f024b793
--- /dev/null
+++ b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/HelpScreenExample.java
@@ -0,0 +1,35 @@
+package joptsimple.examples;
+
+import java.io.File;
+
+import static java.io.File.*;
+import static java.util.Arrays.*;
+
+import joptsimple.OptionParser;
+
+import static joptsimple.util.DateConverter.*;
+
+public class HelpScreenExample {
+ public static void main( String[] args ) throws Exception {
+ OptionParser parser = new OptionParser() {
+ {
+ accepts( "c" ).withRequiredArg().ofType( Integer.class )
+ .describedAs( "count" ).defaultsTo( 1 );
+ accepts( "q" ).withOptionalArg().ofType( Double.class )
+ .describedAs( "quantity" );
+ accepts( "d", "some date" ).withRequiredArg().required()
+ .withValuesConvertedBy( datePattern( "MM/dd/yy" ) );
+ acceptsAll( asList( "v", "talkative", "chatty" ), "be more verbose" );
+ accepts( "output-file" ).withOptionalArg().ofType( File.class )
+ .describedAs( "file" );
+ acceptsAll( asList( "h", "?" ), "show help" ).forHelp();
+ acceptsAll( asList( "cp", "classpath" ) ).withRequiredArg()
+ .describedAs( "path1" + pathSeparatorChar + "path2:..." )
+ .ofType( File.class )
+ .withValuesSeparatedBy( pathSeparatorChar );
+ }
+ };
+
+ parser.printHelpOn( System.out );
+ }
+}