Editing
CommandLineOptions tutorial
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==So how can <code>CommandLineOptions</code> help?== Here's how it works: '''First''', you replace the command line option parsing with a call to [http://commons.unkrig.de/javadoc/de/unkrig/commons/util/CommandLineOptions.html#parse-java.lang.String:A-java.lang.Object- CommandLineOptions.parse()]. Also add a method for each command line option, annotate it with [http://commons.unkrig.de/javadoc/de/unkrig/commons/util/annotation/CommandLineOption.html @CommandLineOption] and add its description as JAVADOC. Put the usage text into the JAVADOC comment of the "<code>main()</code>" method, with a placeholder "<tt>{@command-line-options}</tt> for the descriptions of the command line options. '''Second''', you generate HTML documentation with the [[Doclet#The_MAIN_Doclet|MAIN doclet]]: <javadoc doclet="de.unkrig.doclet.main.MainDoclet" docletpath="de.unkrig.doclet.main.jar" destdir="src"> <fileset file="src/com/acme/clo_demo/Diff.java" /> </javadoc> '''Third''', you convert the HTML documentation into plain text with the [http://html2txt.unkrig.de HTML2TXT] utility: <taskdef classpath="html2txt.jar" resource="de/unkrig/html2txt/antlib.xml" /> <html2txt> <fileset dir="src" includes="com/acme/clo_demo/Diff.main(String[]).html" /> </html2txt> '''Fourth''', rewrite the "<tt>--help</tt>" option to simply copy the plain text documentation to <code>System.out</code>.
Summary:
Please note that all contributions to unkrig.de may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Unkrig.de:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help
Tools
What links here
Related changes
Special pages
Page information