Revision 2398 tmp/org.txm.libs.args4j/src/org/kohsuke/args4j/package.html

package.html (revision 2398)
1
<html><body>
2
<p>Core classes of the Args4J command line parser.</p>
1
<html>
2
<body>
3
	<p>Core classes of the Args4J command line parser.</p>
3 4

  
4
<h1>What is Args4J</h1>
5
<p>Args4J is a command line parser. As such a parser its job is to parse the String-array passed to the main() method
6
and transfer the values to a java object, which includes type conversion. The entry point into this parsing is
7
the CmdLineParser class with its parse() Method.</p>
8
<p>Args4J must know the mapping between the flag from the command line and the target for the value.
9
There are multiple ways for Args4J: <ul>
10
    <li>place an @Option or @Argument annotation at a setter or on a field</li>
11
    <li>provide a XML configuration file</li>
12
    <li>make all fields public available</li>
13
</ul> 
14
depending on what you want, you have to do a configuration step before starting the parsing.</p>
5
	<h1>What is Args4J</h1>
6
	<p>Args4J is a command line parser. As such a parser its job is to
7
		parse the String-array passed to the main() method and transfer the
8
		values to a java object, which includes type conversion. The entry
9
		point into this parsing is the CmdLineParser class with its parse()
10
		Method.</p>
11
	<p>Args4J must know the mapping between the flag from the command
12
		line and the target for the value. There are multiple ways for Args4J:
13
	
14
	<ul>
15
		<li>place an @Option or @Argument annotation at a setter or on a
16
			field</li>
17
		<li>provide a XML configuration file</li>
18
		<li>make all fields public available</li>
19
	</ul>
20
	depending on what you want, you have to do a configuration step before
21
	starting the parsing.
22
	</p>
15 23

  
16
<h1>Examples</h1>
24
	<h1>Examples</h1>
17 25

  
18
<p><tt>java Main -text newText</tt></p>
26
	<p>
27
		<tt>java Main -text newText</tt>
28
	</p>
19 29

  
20
<p>The standard use case is having a bean class and providing the annotations.
21
This feature is available since the first Args4J release:
22
<!-- TODO: 
30
	<p>
31
		The standard use case is having a bean class and providing the
32
		annotations. This feature is available since the first Args4J release:
33
		<!-- TODO: 
23 34
Javadoc stops when reaching the at-sign. When I load the package.html directly into Firefox,
24 35
all is fine. But when creating the javadoc it stops copying the content at that sign.
25 36
(a) is a compromise here ...
26 37
Does anyone know how to handle that?
27 38
-->
28
<pre>
39
	<pre>
29 40
public class Bean {
30 41
    (a)Option(name="-text")
31 42
    String text;
......
39 50
}
40 51
</pre>
41 52

  
42
<p>An easy way for initializing fields and not touching the bean source code
43
is using the FieldParser. The FieldParser scans all fields of the bean class
44
(including inheritance) and makes them public available as options with 
45
a '-' prefix in the name.
46
This feature is available since Args4J release 2.0.16:
47
<pre>
53
	<p>An easy way for initializing fields and not touching the bean
54
		source code is using the FieldParser. The FieldParser scans all fields
55
		of the bean class (including inheritance) and makes them public
56
		available as options with a '-' prefix in the name. This feature is
57
		available since Args4J release 2.0.16:
58
	<pre>
48 59
public class Bean {
49 60
    String text;
50 61
}
......
58 69
}
59 70
</pre>
60 71

  
61
<p>While the FieldParser is easier to use, the XmlParser supports more features. 
62
That said it supports all features which are available via annotations: usage text, specifying handlers and more.
63
You have to provide an XML InputSource or an URL to the XML file. 
64
This feature is available since Args4J release 2.0.16:
65
<pre>
72
	<p>While the FieldParser is easier to use, the XmlParser supports
73
		more features. That said it supports all features which are available
74
		via annotations: usage text, specifying handlers and more. You have to
75
		provide an XML InputSource or an URL to the XML file. This feature is
76
		available since Args4J release 2.0.16:
77
	<pre>
66 78
public class Bean {
67 79
    String text;
68 80
}
......
78 90
  &lt;option field="text" name="-text" usage="Output text"/>
79 91
&lt;/args>
80 92
</pre>
81
</p>
93
	</p>
82 94

  
83 95

  
84
</body></html>
96
</body>
97
</html>

Also available in: Unified diff