diff options
author | Cedric Beust <cedric@beust.com> | 2010-07-13 21:15:59 -0700 |
---|---|---|
committer | Cedric Beust <cedric@beust.com> | 2010-07-13 21:15:59 -0700 |
commit | db7a571f6cc481746c1a7e0f4d3100e47b22b18f (patch) | |
tree | 3b82980b57d361379cd5eb45e43da9c8045f1654 /doc | |
parent | dc76d5707bd6f5b761772203e9d7c285846e8362 (diff) | |
download | platform_external_jcommander-db7a571f6cc481746c1a7e0f4d3100e47b22b18f.tar.gz platform_external_jcommander-db7a571f6cc481746c1a7e0f4d3100e47b22b18f.tar.bz2 platform_external_jcommander-db7a571f6cc481746c1a7e0f4d3100e47b22b18f.zip |
Doc for required and exceptions
Diffstat (limited to 'doc')
-rw-r--r-- | doc/index.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/index.html b/doc/index.html index 37b7254..fa1c7c7 100644 --- a/doc/index.html +++ b/doc/index.html @@ -184,6 +184,29 @@ java Main -d /tmp java Main --outputDirectory /tmp </pre> +<h2>Required and optional parameters</h2> + +If some of your parameters are mandatory, you can use the +<tt>required</tt> attribute (which default to <tt>false</tt>): + +<pre class="brush: java"> + + @Parameter(names = "-host", required = true) + public String host; + +</pre> + +If this parameter is not specified, JCommander will throw an exception +telling you which options are missing. + +<h2>Exception</h2> + +Whenever JCommander detects an error, it will throw a +<tt>ParameterException</tt>. Note that this is a Runtime Exception, +since your application is probably not initialized correctly at this +point. + + <h2>Usage</h2> You can invoke <tt>usage()</tt> on the <tt>JCommander</tt> instance that you used to parse your command line in order to generate a summary of all the options that your program understands: |