1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta charset="UTF-8">
5<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
6<meta name="viewport" content="width=device-width, initial-scale=1.0">
7<meta name="generator" content="Asciidoctor 1.5.5">
8<meta name="author" content="Cédric Beust">
9<title>JCommander</title>
10<style>
11@import url(https://fonts.googleapis.com/css?family=Varela+Round|Open+Sans:400italic,600italic,400,600|Ubuntu+Mono:400);
12/*! normalize.css v2.1.2 | MIT License | git.io/normalize */
13/* ========================================================================== HTML5 display definitions ========================================================================== */
14/** Correct `block` display not defined in IE 8/9. */
15article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; }
16
17/** Correct `inline-block` display not defined in IE 8/9. */
18audio, canvas, video { display: inline-block; }
19
20/** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */
21audio:not([controls]) { display: none; height: 0; }
22
23/** Address `[hidden]` styling not present in IE 8/9. Hide the `template` element in IE, Safari, and Firefox < 22. */
24[hidden], template { display: none; }
25
26script { display: none !important; }
27
28/* ========================================================================== Base ========================================================================== */
29/** 1. Set default font family to sans-serif. 2. Prevent iOS text size adjust after orientation change, without disabling user zoom. */
30html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ }
31
32/** Remove default margin. */
33body { margin: 0; }
34
35/* ========================================================================== Links ========================================================================== */
36/** Remove the gray background color from active links in IE 10. */
37a { background: transparent; }
38
39/** Address `outline` inconsistency between Chrome and other browsers. */
40a:focus { outline: thin dotted; }
41
42/** Improve readability when focused and also mouse hovered in all browsers. */
43a:active, a:hover { outline: 0; }
44
45/* ========================================================================== Typography ========================================================================== */
46/** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari 5, and Chrome. */
47h1 { font-size: 2em; margin: 0.67em 0; }
48
49/** Address styling not present in IE 8/9, Safari 5, and Chrome. */
50abbr[title] { border-bottom: 1px dotted; }
51
52/** Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. */
53b, strong { font-weight: bold; }
54
55/** Address styling not present in Safari 5 and Chrome. */
56dfn { font-style: italic; }
57
58/** Address differences between Firefox and other browsers. */
59hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; }
60
61/** Address styling not present in IE 8/9. */
62mark { background: #ff0; color: #000; }
63
64/** Correct font family set oddly in Safari 5 and Chrome. */
65code, kbd, pre, samp { font-family: monospace, serif; font-size: 1em; }
66
67/** Improve readability of pre-formatted text in all browsers. */
68pre { white-space: pre-wrap; }
69
70/** Set consistent quote types. */
71q { quotes: "\201C" "\201D" "\2018" "\2019"; }
72
73/** Address inconsistent and variable font size in all browsers. */
74small { font-size: 80%; }
75
76/** Prevent `sub` and `sup` affecting `line-height` in all browsers. */
77sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
78
79sup { top: -0.5em; }
80
81sub { bottom: -0.25em; }
82
83/* ========================================================================== Embedded content ========================================================================== */
84/** Remove border when inside `a` element in IE 8/9. */
85img { border: 0; }
86
87/** Correct overflow displayed oddly in IE 9. */
88svg:not(:root) { overflow: hidden; }
89
90/* ========================================================================== Figures ========================================================================== */
91/** Address margin not present in IE 8/9 and Safari 5. */
92figure { margin: 0; }
93
94/* ========================================================================== Forms ========================================================================== */
95/** Define consistent border, margin, and padding. */
96fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; }
97
98/** 1. Correct `color` not being inherited in IE 8/9. 2. Remove padding so people aren't caught out if they zero out fieldsets. */
99legend { border: 0; /* 1 */ padding: 0; /* 2 */ }
100
101/** 1. Correct font family not being inherited in all browsers. 2. Correct font size not being inherited in all browsers. 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. */
102button, input, select, textarea { font-family: inherit; /* 1 */ font-size: 100%; /* 2 */ margin: 0; /* 3 */ }
103
104/** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */
105button, input { line-height: normal; }
106
107/** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. Correct `select` style inheritance in Firefox 4+ and Opera. */
108button, select { text-transform: none; }
109
110/** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */
111button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ }
112
113/** Re-set default cursor for disabled elements. */
114button[disabled], html input[disabled] { cursor: default; }
115
116/** 1. Address box sizing set to `content-box` in IE 8/9. 2. Remove excess padding in IE 8/9. */
117input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ }
118
119/** 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome (include `-moz` to future-proof). */
120input[type="search"] { -webkit-appearance: textfield; /* 1 */ -moz-box-sizing: content-box; -webkit-box-sizing: content-box; /* 2 */ box-sizing: content-box; }
121
122/** Remove inner padding and search cancel button in Safari 5 and Chrome on OS X. */
123input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
124
125/** Remove inner padding and border in Firefox 4+. */
126button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
127
128/** 1. Remove default vertical scrollbar in IE 8/9. 2. Improve readability and alignment in all browsers. */
129textarea { overflow: auto; /* 1 */ vertical-align: top; /* 2 */ }
130
131/* ========================================================================== Tables ========================================================================== */
132/** Remove most spacing between table cells. */
133table { border-collapse: collapse; border-spacing: 0; }
134
135meta.foundation-mq-small { font-family: "only screen and (min-width: 768px)"; width: 768px; }
136
137meta.foundation-mq-medium { font-family: "only screen and (min-width:1280px)"; width: 1280px; }
138
139meta.foundation-mq-large { font-family: "only screen and (min-width:1440px)"; width: 1440px; }
140
141*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
142
143html, body { font-size: 100%; }
144
145body { background: #fefdfd; color: rgba(0, 0, 0, 0.8); padding: 0; margin: 0; font-family: "Open Sans", sans-serif; font-weight: normal; font-style: normal; line-height: 1; position: relative; cursor: auto; }
146
147a:hover { cursor: pointer; }
148
149img, object, embed { max-width: 100%; height: auto; }
150
151object, embed { height: 100%; }
152
153img { -ms-interpolation-mode: bicubic; }
154
155#map_canvas img, #map_canvas embed, #map_canvas object, .map_canvas img, .map_canvas embed, .map_canvas object { max-width: none !important; }
156
157.left { float: left !important; }
158
159.right { float: right !important; }
160
161.text-left { text-align: left !important; }
162
163.text-right { text-align: right !important; }
164
165.text-center { text-align: center !important; }
166
167.text-justify { text-align: justify !important; }
168
169.hide { display: none; }
170
171.antialiased { -webkit-font-smoothing: antialiased; }
172
173img { display: inline-block; vertical-align: middle; }
174
175textarea { height: auto; min-height: 50px; }
176
177select { width: 100%; }
178
179object, svg { display: inline-block; vertical-align: middle; }
180
181.center { margin-left: auto; margin-right: auto; }
182
183.spread { width: 100%; }
184
185p.lead, .paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { font-size: 1.21875em; line-height: 1.6; }
186
187.subheader, .admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { line-height: 1.25; color: #002c5e; font-weight: 300; margin-top: 0.2em; margin-bottom: 0.5em; }
188
189/* Typography resets */
190div, dl, dt, dd, ul, ol, li, h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6, pre, form, p, blockquote, th, td { margin: 0; padding: 0; direction: ltr; }
191
192/* Default Link Styles */
193a { color: #005580; text-decoration: underline; line-height: inherit; }
194a:hover, a:focus { color: #078d71; }
195a img { border: none; }
196
197/* Default paragraph styles */
198p { font-family: inherit; font-weight: normal; font-size: 1em; line-height: 1.5; margin-bottom: 1.25em; text-rendering: optimizeLegibility; }
199p aside { font-size: 0.875em; line-height: 1.35; font-style: italic; }
200
201/* Default header styles */
202h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { font-family: "Varela Round", sans-serif; font-weight: 400; font-style: normal; color: #00326b; text-rendering: optimizeLegibility; margin-top: 0.8em; margin-bottom: 0.5em; line-height: 1.0625em; }
203h1 small, h2 small, h3 small, #toctitle small, .sidebarblock > .content > .title small, h4 small, h5 small, h6 small { font-size: 60%; color: #057aff; line-height: 0; }
204
205h1 { font-size: 2.125em; }
206
207h2 { font-size: 1.6875em; }
208
209h3, #toctitle, .sidebarblock > .content > .title { font-size: 1.375em; }
210
211h4 { font-size: 1.125em; }
212
213h5 { font-size: 1.125em; }
214
215h6 { font-size: 1em; }
216
217hr { border: solid rgba(145, 135, 84, 0.15); border-width: 1px 0 0; clear: both; margin: 1.25em 0 1.1875em; height: 0; }
218
219/* Helpful Typography Defaults */
220em, i { font-style: italic; line-height: inherit; }
221
222strong, b { font-weight: bold; line-height: inherit; }
223
224small { font-size: 60%; line-height: inherit; }
225
226code { font-family: "Ubuntu Mono", "Inconsolata", monospace; font-weight: 400; color: #331d00; }
227
228/* Lists */
229ul, ol, dl { font-size: 1em; line-height: 1.5; margin-bottom: 1.25em; list-style-position: outside; font-family: inherit; }
230
231ul, ol { margin-left: 1.5em; }
232ul.no-bullet, ol.no-bullet { margin-left: 1.5em; }
233
234/* Unordered Lists */
235ul li ul, ul li ol { margin-left: 1.25em; margin-bottom: 0; font-size: 1em; /* Override nested font-size change */ }
236ul.square li ul, ul.circle li ul, ul.disc li ul { list-style: inherit; }
237ul.square { list-style-type: square; }
238ul.circle { list-style-type: circle; }
239ul.disc { list-style-type: disc; }
240ul.no-bullet { list-style: none; }
241
242/* Ordered Lists */
243ol li ul, ol li ol { margin-left: 1.25em; margin-bottom: 0; }
244
245/* Definition Lists */
246dl dt { margin-bottom: 0.3125em; font-weight: bold; }
247dl dd { margin-bottom: 1.25em; }
248
249/* Abbreviations */
250abbr, acronym { text-transform: uppercase; font-size: 90%; color: rgba(0, 0, 0, 0.8); border-bottom: 1px dotted #dddddd; cursor: help; }
251
252abbr { text-transform: none; }
253
254/* Blockquotes */
255blockquote { margin: 0 0 1.25em; padding: 0.5625em 1.25em 0 1.1875em; border-left: 1px solid #dddddd; }
256blockquote cite { display: block; font-size: 0.8125em; color: #666666; }
257blockquote cite:before { content: "\2014 \0020"; }
258blockquote cite a, blockquote cite a:visited { color: #666666; }
259
260blockquote, blockquote p { line-height: 1.5; color: #999999; }
261
262/* Microformats */
263.vcard { display: inline-block; margin: 0 0 1.25em 0; border: 1px solid #dddddd; padding: 0.625em 0.75em; }
264.vcard li { margin: 0; display: block; }
265.vcard .fn { font-weight: bold; font-size: 0.9375em; }
266
267.vevent .summary { font-weight: bold; }
268.vevent abbr { cursor: auto; text-decoration: none; font-weight: bold; border: none; padding: 0 0.0625em; }
269
270@media only screen and (min-width: 768px) { h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { line-height: 1.25; }
271  h1 { font-size: 2.75em; }
272  h2 { font-size: 2.3125em; }
273  h3, #toctitle, .sidebarblock > .content > .title { font-size: 1.6875em; }
274  h4 { font-size: 1.4375em; } }
275/* Tables */
276table { background: white; margin-bottom: 1.25em; border: solid 1px rgba(145, 135, 84, 0.15); }
277table thead, table tfoot { background: rgba(119, 84, 22, 0.1); font-weight: bold; }
278table thead tr th, table thead tr td, table tfoot tr th, table tfoot tr td { padding: 0.5em 0.625em 0.625em; font-size: inherit; color: rgba(0, 0, 0, 0.8); text-align: left; }
279table tr th, table tr td { padding: 0.5625em 0.625em; font-size: inherit; color: rgba(0, 0, 0, 0.8); }
280table tr.even, table tr.alt, table tr:nth-of-type(even) { background: rgba(119, 84, 22, 0.025); }
281table thead tr th, table tfoot tr th, table tbody tr td, table tr td, table tfoot tr td { display: table-cell; line-height: 1.5; }
282
283body { -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; tab-size: 4; }
284
285h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { line-height: 1.25; }
286
287.clearfix:before, .clearfix:after, .float-group:before, .float-group:after { content: " "; display: table; }
288.clearfix:after, .float-group:after { clear: both; }
289
290*:not(pre) > code { font-size: 1.0625em; font-style: normal !important; letter-spacing: 0; padding: 0; line-height: 1.25; word-wrap: break-word; }
291*:not(pre) > code.nobreak { word-wrap: normal; }
292*:not(pre) > code.nowrap { white-space: nowrap; }
293
294pre, pre > code { line-height: 1.4; color: inherit; font-family: "Liberation Mono", "Consolas", monospace; font-weight: normal; }
295
296em em { font-style: normal; }
297
298strong strong { font-weight: normal; }
299
300.keyseq { color: rgba(51, 51, 51, 0.8); }
301
302kbd { font-family: "Ubuntu Mono", "Inconsolata", monospace; display: inline-block; color: rgba(0, 0, 0, 0.8); font-size: 0.65em; line-height: 1.45; background-color: #f7f7f7; border: 1px solid #ccc; -webkit-border-radius: 3px; border-radius: 3px; -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 0.1em white inset; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 0.1em white inset; margin: 0 0.15em; padding: 0.2em 0.5em; vertical-align: middle; position: relative; top: -0.1em; white-space: nowrap; }
303
304.keyseq kbd:first-child { margin-left: 0; }
305
306.keyseq kbd:last-child { margin-right: 0; }
307
308.menuseq, .menu { color: rgba(0, 0, 0, 0.8); }
309
310b.button:before, b.button:after { position: relative; top: -1px; font-weight: normal; }
311
312b.button:before { content: "["; padding: 0 3px 0 2px; }
313
314b.button:after { content: "]"; padding: 0 2px 0 3px; }
315
316p a > code:hover { color: #1a0f00; }
317
318#header, #content, #footnotes, #footer { width: 100%; margin-left: auto; margin-right: auto; margin-top: 0; margin-bottom: 0; max-width: 62.5em; *zoom: 1; position: relative; padding-left: 0.9375em; padding-right: 0.9375em; }
319#header:before, #header:after, #content:before, #content:after, #footnotes:before, #footnotes:after, #footer:before, #footer:after { content: " "; display: table; }
320#header:after, #content:after, #footnotes:after, #footer:after { clear: both; }
321
322#content { margin-top: 1.25em; }
323
324#content:before { content: none; }
325
326#header > h1:first-child { color: #703f1c; margin-top: 2.25rem; margin-bottom: 0; }
327#header > h1:first-child + #toc { margin-top: 8px; border-top: 1px solid rgba(145, 135, 84, 0.15); }
328#header > h1:only-child, body.toc2 #header > h1:nth-last-child(2) { border-bottom: 1px solid rgba(145, 135, 84, 0.15); padding-bottom: 8px; }
329#header .details { border-bottom: 1px solid rgba(145, 135, 84, 0.15); line-height: 1.45; padding-top: 0.25em; padding-bottom: 0.25em; padding-left: 0.25em; color: #666666; display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-flow: row wrap; -webkit-flex-flow: row wrap; flex-flow: row wrap; }
330#header .details span:first-child { margin-left: -0.125em; }
331#header .details span.email a { color: #999999; }
332#header .details br { display: none; }
333#header .details br + span:before { content: "\00a0\2013\00a0"; }
334#header .details br + span.author:before { content: "\00a0\22c5\00a0"; color: #999999; }
335#header .details br + span#revremark:before { content: "\00a0|\00a0"; }
336#header #revnumber { text-transform: capitalize; }
337#header #revnumber:after { content: "\00a0"; }
338
339#content > h1:first-child:not([class]) { color: #703f1c; border-bottom: 1px solid rgba(145, 135, 84, 0.15); padding-bottom: 8px; margin-top: 0; padding-top: 1rem; margin-bottom: 1.25rem; }
340
341#toc { border-bottom: 0px solid #dddddd; padding-bottom: 0.5em; }
342#toc > ul { margin-left: 0.125em; }
343#toc ul.sectlevel0 > li > a { font-style: italic; }
344#toc ul.sectlevel0 ul.sectlevel1 { margin: 0.5em 0; }
345#toc ul { font-family: "Varela Round", sans-serif; list-style-type: none; }
346#toc li { line-height: 1.3334; margin-top: 0.3334em; }
347#toc a { text-decoration: none; }
348#toc a:active { text-decoration: underline; }
349
350#toctitle { color: #002c5e; font-size: 1.2em; }
351
352@media only screen and (min-width: 768px) { #toctitle { font-size: 1.375em; }
353  body.toc2 { padding-left: 15em; padding-right: 0; }
354  #toc.toc2 { margin-top: 0 !important; background-color: #f2f2f4; position: fixed; width: 15em; left: 0; top: 0; border-right: 1px solid #dddddd; border-top-width: 0 !important; border-bottom-width: 0 !important; z-index: 1000; padding: 1.25em 1em; height: 100%; overflow: auto; }
355  #toc.toc2 #toctitle { margin-top: 0; margin-bottom: 0.8rem; font-size: 1.2em; }
356  #toc.toc2 > ul { font-size: 0.9em; margin-bottom: 0; }
357  #toc.toc2 ul ul { margin-left: 0; padding-left: 1em; }
358  #toc.toc2 ul.sectlevel0 ul.sectlevel1 { padding-left: 0; margin-top: 0.5em; margin-bottom: 0.5em; }
359  body.toc2.toc-right { padding-left: 0; padding-right: 15em; }
360  body.toc2.toc-right #toc.toc2 { border-right-width: 0; border-left: 1px solid #dddddd; left: auto; right: 0; } }
361@media only screen and (min-width: 1280px) { body.toc2 { padding-left: 20em; padding-right: 0; }
362  #toc.toc2 { width: 20em; }
363  #toc.toc2 #toctitle { font-size: 1.375em; }
364  #toc.toc2 > ul { font-size: 0.95em; }
365  #toc.toc2 ul ul { padding-left: 1.25em; }
366  body.toc2.toc-right { padding-left: 0; padding-right: 20em; } }
367#content #toc { border-style: solid; border-width: 1px; border-color: #d6d6dd; margin-bottom: 1.25em; padding: 1.25em; background: #f2f2f4; -webkit-border-radius: 6px; border-radius: 6px; }
368#content #toc > :first-child { margin-top: 0; }
369#content #toc > :last-child { margin-bottom: 0; }
370
371#footer { max-width: 100%; background-color: #0b445a; padding: 1.25em; }
372
373#footer-text { color: #fefdfd; line-height: 1.35; }
374
375.sect1 { padding-bottom: 0.625em; }
376
377@media only screen and (min-width: 768px) { .sect1 { padding-bottom: 1.25em; } }
378.sect1 + .sect1 { border-top: 0px solid #dddddd; }
379
380#content h1 > a.anchor, h2 > a.anchor, h3 > a.anchor, #toctitle > a.anchor, .sidebarblock > .content > .title > a.anchor, h4 > a.anchor, h5 > a.anchor, h6 > a.anchor { position: absolute; z-index: 1001; width: 1.5ex; margin-left: -1.5ex; display: block; text-decoration: none !important; visibility: hidden; text-align: center; font-weight: normal; }
381#content h1 > a.anchor:before, h2 > a.anchor:before, h3 > a.anchor:before, #toctitle > a.anchor:before, .sidebarblock > .content > .title > a.anchor:before, h4 > a.anchor:before, h5 > a.anchor:before, h6 > a.anchor:before { content: "\00A7"; font-size: 0.85em; display: block; padding-top: 0.1em; }
382#content h1:hover > a.anchor, #content h1 > a.anchor:hover, h2:hover > a.anchor, h2 > a.anchor:hover, h3:hover > a.anchor, #toctitle:hover > a.anchor, .sidebarblock > .content > .title:hover > a.anchor, h3 > a.anchor:hover, #toctitle > a.anchor:hover, .sidebarblock > .content > .title > a.anchor:hover, h4:hover > a.anchor, h4 > a.anchor:hover, h5:hover > a.anchor, h5 > a.anchor:hover, h6:hover > a.anchor, h6 > a.anchor:hover { visibility: visible; }
383#content h1 > a.link, h2 > a.link, h3 > a.link, #toctitle > a.link, .sidebarblock > .content > .title > a.link, h4 > a.link, h5 > a.link, h6 > a.link { color: #00326b; text-decoration: none; }
384#content h1 > a.link:hover, h2 > a.link:hover, h3 > a.link:hover, #toctitle > a.link:hover, .sidebarblock > .content > .title > a.link:hover, h4 > a.link:hover, h5 > a.link:hover, h6 > a.link:hover { color: #002652; }
385
386.audioblock, .imageblock, .literalblock, .listingblock, .stemblock, .videoblock { margin-bottom: 1.25em; }
387
388.admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { text-rendering: optimizeLegibility; text-align: left; }
389
390table.tableblock > caption.title { white-space: nowrap; overflow: visible; max-width: 0; }
391
392.paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { color: #703f1c; }
393
394table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p { font-size: inherit; }
395
396.admonitionblock > table { border-collapse: separate; border: 0; background: none; width: 100%; }
397.admonitionblock > table td.icon { text-align: center; width: 80px; }
398.admonitionblock > table td.icon img { max-width: initial; }
399.admonitionblock > table td.icon .title { font-weight: bold; font-family: "Varela Round", sans-serif; text-transform: uppercase; }
400.admonitionblock > table td.content { padding-left: 1.125em; padding-right: 1.25em; border-left: 1px solid rgba(145, 135, 84, 0.15); color: #666666; }
401.admonitionblock > table td.content > :last-child > :last-child { margin-bottom: 0; }
402
403.exampleblock > .content { border-style: solid; border-width: 1px; border-color: #eddbdb; margin-bottom: 1.25em; padding: 1.25em; background: #fefdfd; -webkit-border-radius: 6px; border-radius: 6px; }
404.exampleblock > .content > :first-child { margin-top: 0; }
405.exampleblock > .content > :last-child { margin-bottom: 0; }
406
407.sidebarblock { border-style: solid; border-width: 1px; border-color: #d6d6dd; margin-bottom: 1.25em; padding: 1.25em; background: #f2f2f4; -webkit-border-radius: 6px; border-radius: 6px; }
408.sidebarblock > :first-child { margin-top: 0; }
409.sidebarblock > :last-child { margin-bottom: 0; }
410.sidebarblock > .content > .title { color: #002c5e; margin-top: 0; }
411
412.exampleblock > .content > :last-child > :last-child, .exampleblock > .content .olist > ol > li:last-child > :last-child, .exampleblock > .content .ulist > ul > li:last-child > :last-child, .exampleblock > .content .qlist > ol > li:last-child > :last-child, .sidebarblock > .content > :last-child > :last-child, .sidebarblock > .content .olist > ol > li:last-child > :last-child, .sidebarblock > .content .ulist > ul > li:last-child > :last-child, .sidebarblock > .content .qlist > ol > li:last-child > :last-child { margin-bottom: 0; }
413
414.literalblock pre, .listingblock pre:not(.highlight), .listingblock pre[class="highlight"], .listingblock pre[class^="highlight "], .listingblock pre.CodeRay, .listingblock pre.prettyprint { background: rgba(16, 195, 196, 0.05); }
415.sidebarblock .literalblock pre, .sidebarblock .listingblock pre:not(.highlight), .sidebarblock .listingblock pre[class="highlight"], .sidebarblock .listingblock pre[class^="highlight "], .sidebarblock .listingblock pre.CodeRay, .sidebarblock .listingblock pre.prettyprint { background: #f2f1f1; }
416
417.literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { border: 1px solid rgba(16, 195, 196, 0.125); -webkit-border-radius: 6px; border-radius: 6px; word-wrap: break-word; padding: 1em; font-size: 0.8125em; }
418.literalblock pre.nowrap, .literalblock pre[class].nowrap, .listingblock pre.nowrap, .listingblock pre[class].nowrap { overflow-x: auto; white-space: pre; word-wrap: normal; }
419@media only screen and (min-width: 768px) { .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { font-size: 0.90625em; } }
420@media only screen and (min-width: 1280px) { .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { font-size: 1em; } }
421
422.literalblock.output pre { color: rgba(16, 195, 196, 0.05); background-color: inherit; }
423
424.listingblock pre.highlightjs { padding: 0; }
425.listingblock pre.highlightjs > code { padding: 1em; -webkit-border-radius: 6px; border-radius: 6px; }
426
427.listingblock > .content { position: relative; }
428
429.listingblock code[data-lang]:before { display: none; content: attr(data-lang); position: absolute; font-size: 0.75em; top: 0.425rem; right: 0.5rem; line-height: 1; text-transform: uppercase; color: #999; }
430
431.listingblock:hover code[data-lang]:before { display: block; }
432
433.listingblock.terminal pre .command:before { content: attr(data-prompt); padding-right: 0.5em; color: #999; }
434
435.listingblock.terminal pre .command:not([data-prompt]):before { content: "$"; }
436
437table.pyhltable { border-collapse: separate; border: 0; margin-bottom: 0; background: none; }
438
439table.pyhltable td { vertical-align: top; padding-top: 0; padding-bottom: 0; line-height: 1.4; }
440
441table.pyhltable td.code { padding-left: .75em; padding-right: 0; }
442
443pre.pygments .lineno, table.pyhltable td:not(.code) { color: #999; padding-left: 0; padding-right: .5em; border-right: 1px solid rgba(145, 135, 84, 0.15); }
444
445pre.pygments .lineno { display: inline-block; margin-right: .25em; }
446
447table.pyhltable .linenodiv { background: none !important; padding-right: 0 !important; }
448
449.quoteblock { margin: 0 1em 1.25em 1.5em; display: table; }
450.quoteblock > .title { margin-left: -1.5em; margin-bottom: 0.75em; }
451.quoteblock blockquote, .quoteblock blockquote p { color: #999999; font-size: 1.15rem; line-height: 1.75; word-spacing: 0.1em; letter-spacing: 0; font-style: italic; text-align: justify; }
452.quoteblock blockquote { margin: 0; padding: 0; border: 0; }
453.quoteblock blockquote:before { content: "\201c"; float: left; font-size: 2.75em; font-weight: bold; line-height: 0.6em; margin-left: -0.6em; color: #002c5e; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
454.quoteblock blockquote > .paragraph:last-child p { margin-bottom: 0; }
455.quoteblock .attribution { margin-top: 0.5em; margin-right: 0.5ex; text-align: right; }
456.quoteblock .quoteblock { margin-left: 0; margin-right: 0; padding: 0.5em 0; border-left: 3px solid #666666; }
457.quoteblock .quoteblock blockquote { padding: 0 0 0 0.75em; }
458.quoteblock .quoteblock blockquote:before { display: none; }
459
460.verseblock { margin: 0 1em 1.25em 1em; }
461.verseblock pre { font-family: "Open Sans", "DejaVu Sans", sans; font-size: 1.15rem; color: #999999; font-weight: 300; text-rendering: optimizeLegibility; }
462.verseblock pre strong { font-weight: 400; }
463.verseblock .attribution { margin-top: 1.25rem; margin-left: 0.5ex; }
464
465.quoteblock .attribution, .verseblock .attribution { font-size: 0.8125em; line-height: 1.45; font-style: italic; }
466.quoteblock .attribution br, .verseblock .attribution br { display: none; }
467.quoteblock .attribution cite, .verseblock .attribution cite { display: block; letter-spacing: -0.025em; color: #666666; }
468
469.quoteblock.abstract { margin: 0 0 1.25em 0; display: block; }
470.quoteblock.abstract blockquote, .quoteblock.abstract blockquote p { text-align: left; word-spacing: 0; }
471.quoteblock.abstract blockquote:before, .quoteblock.abstract blockquote p:first-of-type:before { display: none; }
472
473table.tableblock { max-width: 100%; border-collapse: separate; }
474table.tableblock td > .paragraph:last-child p > p:last-child, table.tableblock th > p:last-child, table.tableblock td > p:last-child { margin-bottom: 0; }
475
476table.tableblock, th.tableblock, td.tableblock { border: 0 solid rgba(145, 135, 84, 0.15); }
477
478table.grid-all th.tableblock, table.grid-all td.tableblock { border-width: 0 1px 1px 0; }
479
480table.grid-all tfoot > tr > th.tableblock, table.grid-all tfoot > tr > td.tableblock { border-width: 1px 1px 0 0; }
481
482table.grid-cols th.tableblock, table.grid-cols td.tableblock { border-width: 0 1px 0 0; }
483
484table.grid-all * > tr > .tableblock:last-child, table.grid-cols * > tr > .tableblock:last-child { border-right-width: 0; }
485
486table.grid-rows th.tableblock, table.grid-rows td.tableblock { border-width: 0 0 1px 0; }
487
488table.grid-all tbody > tr:last-child > th.tableblock, table.grid-all tbody > tr:last-child > td.tableblock, table.grid-all thead:last-child > tr > th.tableblock, table.grid-rows tbody > tr:last-child > th.tableblock, table.grid-rows tbody > tr:last-child > td.tableblock, table.grid-rows thead:last-child > tr > th.tableblock { border-bottom-width: 0; }
489
490table.grid-rows tfoot > tr > th.tableblock, table.grid-rows tfoot > tr > td.tableblock { border-width: 1px 0 0 0; }
491
492table.frame-all { border-width: 1px; }
493
494table.frame-sides { border-width: 0 1px; }
495
496table.frame-topbot { border-width: 1px 0; }
497
498th.halign-left, td.halign-left { text-align: left; }
499
500th.halign-right, td.halign-right { text-align: right; }
501
502th.halign-center, td.halign-center { text-align: center; }
503
504th.valign-top, td.valign-top { vertical-align: top; }
505
506th.valign-bottom, td.valign-bottom { vertical-align: bottom; }
507
508th.valign-middle, td.valign-middle { vertical-align: middle; }
509
510table thead th, table tfoot th { font-weight: bold; }
511
512tbody tr th { display: table-cell; line-height: 1.5; background: rgba(119, 84, 22, 0.1); }
513
514tbody tr th, tbody tr th p, tfoot tr th, tfoot tr th p { color: rgba(0, 0, 0, 0.8); font-weight: bold; }
515
516p.tableblock > code:only-child { background: none; padding: 0; }
517
518p.tableblock { font-size: 1em; }
519
520td > div.verse { white-space: pre; }
521
522ol { margin-left: 1.75em; }
523
524ul li ol { margin-left: 1.5em; }
525
526dl dd { margin-left: 1.125em; }
527
528dl dd:last-child, dl dd:last-child > :last-child { margin-bottom: 0; }
529
530ol > li p, ul > li p, ul dd, ol dd, .olist .olist, .ulist .ulist, .ulist .olist, .olist .ulist { margin-bottom: 0.625em; }
531
532ul.unstyled, ol.unnumbered, ul.checklist, ul.none { list-style-type: none; }
533
534ul.unstyled, ol.unnumbered, ul.checklist { margin-left: 0.625em; }
535
536ul.checklist li > p:first-child > .fa-square-o:first-child, ul.checklist li > p:first-child > .fa-check-square-o:first-child { width: 1em; font-size: 0.85em; }
537
538ul.checklist li > p:first-child > input[type="checkbox"]:first-child { width: 1em; position: relative; top: 1px; }
539
540ul.inline { margin: 0 auto 0.625em auto; margin-left: -1.375em; margin-right: 0; padding: 0; list-style: none; overflow: hidden; }
541ul.inline > li { list-style: none; float: left; margin-left: 1.375em; display: block; }
542ul.inline > li > * { display: block; }
543
544.unstyled dl dt { font-weight: normal; font-style: normal; }
545
546ol.arabic { list-style-type: decimal; }
547
548ol.decimal { list-style-type: decimal-leading-zero; }
549
550ol.loweralpha { list-style-type: lower-alpha; }
551
552ol.upperalpha { list-style-type: upper-alpha; }
553
554ol.lowerroman { list-style-type: lower-roman; }
555
556ol.upperroman { list-style-type: upper-roman; }
557
558ol.lowergreek { list-style-type: lower-greek; }
559
560.hdlist > table, .colist > table { border: 0; background: none; }
561.hdlist > table > tbody > tr, .colist > table > tbody > tr { background: none; }
562
563td.hdlist1, td.hdlist2 { vertical-align: top; padding: 0 0.625em; }
564
565td.hdlist1 { font-weight: bold; padding-bottom: 1.25em; }
566
567.literalblock + .colist, .listingblock + .colist { margin-top: -0.5em; }
568
569.colist > table tr > td:first-of-type { padding: 0 0.75em; line-height: 1; }
570.colist > table tr > td:first-of-type img { max-width: initial; }
571.colist > table tr > td:last-of-type { padding: 0.25em 0; }
572
573.thumb, .th { line-height: 0; display: inline-block; border: solid 4px white; -webkit-box-shadow: 0 0 0 1px #dddddd; box-shadow: 0 0 0 1px #dddddd; }
574
575.imageblock.left, .imageblock[style*="float: left"] { margin: 0.25em 0.625em 1.25em 0; }
576.imageblock.right, .imageblock[style*="float: right"] { margin: 0.25em 0 1.25em 0.625em; }
577.imageblock > .title { margin-bottom: 0; }
578.imageblock.thumb, .imageblock.th { border-width: 6px; }
579.imageblock.thumb > .title, .imageblock.th > .title { padding: 0 0.125em; }
580
581.image.left, .image.right { margin-top: 0.25em; margin-bottom: 0.25em; display: inline-block; line-height: 0; }
582.image.left { margin-right: 0.625em; }
583.image.right { margin-left: 0.625em; }
584
585a.image { text-decoration: none; display: inline-block; }
586a.image object { pointer-events: none; }
587
588sup.footnote, sup.footnoteref { font-size: 0.875em; position: static; vertical-align: super; }
589sup.footnote a, sup.footnoteref a { text-decoration: none; }
590sup.footnote a:active, sup.footnoteref a:active { text-decoration: underline; }
591
592#footnotes { padding-top: 0.75em; padding-bottom: 0.75em; margin-bottom: 0.625em; }
593#footnotes hr { width: 20%; min-width: 6.25em; margin: -0.25em 0 0.75em 0; border-width: 1px 0 0 0; }
594#footnotes .footnote { padding: 0 0.375em 0 0.225em; line-height: 1.3334; font-size: 0.875em; margin-left: 1.2em; text-indent: -1.05em; margin-bottom: 0.2em; }
595#footnotes .footnote a:first-of-type { font-weight: bold; text-decoration: none; }
596#footnotes .footnote:last-of-type { margin-bottom: 0; }
597#content #footnotes { margin-top: -0.625em; margin-bottom: 0; padding: 0.75em 0; }
598
599.gist .file-data > table { border: 0; background: #fff; width: 100%; margin-bottom: 0; }
600.gist .file-data > table td.line-data { width: 99%; }
601
602div.unbreakable { page-break-inside: avoid; }
603
604.big { font-size: larger; }
605
606.small { font-size: smaller; }
607
608.underline { text-decoration: underline; }
609
610.overline { text-decoration: overline; }
611
612.line-through { text-decoration: line-through; }
613
614.aqua { color: #00bfbf; }
615
616.aqua-background { background-color: #00fafa; }
617
618.black { color: black; }
619
620.black-background { background-color: black; }
621
622.blue { color: #0000bf; }
623
624.blue-background { background-color: #0000fa; }
625
626.fuchsia { color: #bf00bf; }
627
628.fuchsia-background { background-color: #fa00fa; }
629
630.gray { color: #606060; }
631
632.gray-background { background-color: #7d7d7d; }
633
634.green { color: #006000; }
635
636.green-background { background-color: #007d00; }
637
638.lime { color: #00bf00; }
639
640.lime-background { background-color: #00fa00; }
641
642.maroon { color: #600000; }
643
644.maroon-background { background-color: #7d0000; }
645
646.navy { color: #000060; }
647
648.navy-background { background-color: #00007d; }
649
650.olive { color: #606000; }
651
652.olive-background { background-color: #7d7d00; }
653
654.purple { color: #600060; }
655
656.purple-background { background-color: #7d007d; }
657
658.red { color: #bf0000; }
659
660.red-background { background-color: #fa0000; }
661
662.silver { color: #909090; }
663
664.silver-background { background-color: #bcbcbc; }
665
666.teal { color: #006060; }
667
668.teal-background { background-color: #007d7d; }
669
670.white { color: #bfbfbf; }
671
672.white-background { background-color: #fafafa; }
673
674.yellow { color: #bfbf00; }
675
676.yellow-background { background-color: #fafa00; }
677
678span.icon > .fa { cursor: default; }
679
680.admonitionblock td.icon [class^="fa icon-"] { font-size: 2.5em; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); cursor: default; }
681.admonitionblock td.icon .icon-note:before { content: "\f05a"; color: #004060; }
682.admonitionblock td.icon .icon-tip:before { content: "\f0eb"; text-shadow: 1px 1px 2px rgba(155, 155, 0, 0.8); color: #111; }
683.admonitionblock td.icon .icon-warning:before { content: "\f071"; color: #bf6900; }
684.admonitionblock td.icon .icon-caution:before { content: "\f06d"; color: #bf3400; }
685.admonitionblock td.icon .icon-important:before { content: "\f06a"; color: #bf0000; }
686
687.conum[data-value] { display: inline-block; color: #fff !important; background-color: rgba(0, 0, 0, 0.8); -webkit-border-radius: 100px; border-radius: 100px; text-align: center; font-size: 0.75em; width: 1.67em; height: 1.67em; line-height: 1.67em; font-family: "Open Sans", "DejaVu Sans", sans-serif; font-style: normal; font-weight: bold; }
688.conum[data-value] * { color: #fff !important; }
689.conum[data-value] + b { display: none; }
690.conum[data-value]:after { content: attr(data-value); }
691pre .conum[data-value] { position: relative; top: -0.125em; }
692
693b.conum * { color: inherit !important; }
694
695.conum:not([data-value]):empty { display: none; }
696
697#toc.toc2 ul ul { list-style-type: circle; padding-left: 2em; }
698
699.sect1 { padding-bottom: 0 !important; margin-bottom: 2.5em; }
700
701#header h1 { font-weight: bold; position: relative; left: -0.0625em; }
702
703#content h2, #content h3, #content #toctitle, #content .sidebarblock > .content > .title, #content h4, #content h5, #content #toctitle { position: relative; left: -0.0625em; }
704#content h2 { font-weight: bold; }
705
706.paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { color: black; }
707
708pre.pygments.highlight { background-color: rgba(16, 195, 196, 0.05); }
709
710.pygments .tok-err { border: none !important; color: #800000 !important; }
711
712.pygments .tok-c { color: #999 !important; }
713
714</style>
715</head>
716<body class="article toc2 toc-left">
717<div id="header">
718<h1>JCommander</h1>
719<div class="details">
720<span id="author" class="author">Cédric Beust</span><br>
721<span id="email" class="email"><a href="mailto:cedric@beust.com">cedric@beust.com</a></span><br>
722</div>
723<div id="toc" class="toc2">
724<div id="toctitle">Table of Contents</div>
725<ul class="sectlevel1">
726<li><a href="#_overview">1. Overview</a></li>
727<li><a href="#_types_of_options">2. Types of options</a>
728<ul class="sectlevel2">
729<li><a href="#_boolean">2.1. Boolean</a></li>
730<li><a href="#_lists">2.2. Lists</a></li>
731<li><a href="#_password">2.3. Password</a></li>
732<li><a href="#_echo_input">2.4. Echo Input</a></li>
733</ul>
734</li>
735<li><a href="#_custom_types_converters_and_splitters">3. Custom types (converters and splitters)</a>
736<ul class="sectlevel2">
737<li><a href="#single-value">3.1. Custom types - Single value</a></li>
738<li><a href="#list-value">3.2. Custom types - List value</a></li>
739<li><a href="#_splitting">3.3. Splitting</a></li>
740</ul>
741</li>
742<li><a href="#_parameter_validation">4. Parameter validation</a>
743<ul class="sectlevel2">
744<li><a href="#_individual_parameter_validation">4.1. Individual parameter validation</a></li>
745<li><a href="#_global_parameter_validation">4.2. Global parameter validation</a></li>
746</ul>
747</li>
748<li><a href="#_main_parameter">5. Main parameter</a></li>
749<li><a href="#_private_parameters">6. Private parameters</a></li>
750<li><a href="#_parameter_separators">7. Parameter separators</a></li>
751<li><a href="#_multiple_descriptions">8. Multiple descriptions</a></li>
752<li><a href="#__syntax">9. @ syntax</a></li>
753<li><a href="#_arities_multiple_values_for_parameters">10. Arities (multiple values for parameters)</a>
754<ul class="sectlevel2">
755<li><a href="#_fixed_arities">10.1. Fixed arities</a></li>
756<li><a href="#_variable_arities">10.2. Variable arities</a></li>
757</ul>
758</li>
759<li><a href="#_multiple_option_names">11. Multiple option names</a></li>
760<li><a href="#_other_option_configurations">12. Other option configurations</a></li>
761<li><a href="#_required_and_optional_parameters">13. Required and optional parameters</a></li>
762<li><a href="#_default_values">14. Default values</a></li>
763<li><a href="#_help_parameter">15. Help parameter</a></li>
764<li><a href="#_more_complex_syntaxes_commands">16. More complex syntaxes (commands)</a></li>
765<li><a href="#_exception">17. Exception</a></li>
766<li><a href="#_usage">18. Usage</a></li>
767<li><a href="#_hiding_parameters">19. Hiding parameters</a></li>
768<li><a href="#_internationalization">20. Internationalization</a></li>
769<li><a href="#_parameter_delegates">21. Parameter delegates</a></li>
770<li><a href="#_dynamic_parameters">22. Dynamic parameters</a></li>
771<li><a href="#_jcommander_in_other_languages">23. JCommander in other languages</a>
772<ul class="sectlevel2">
773<li><a href="#_kotlin">23.1. Kotlin</a></li>
774<li><a href="#_groovy">23.2. Groovy</a></li>
775</ul>
776</li>
777<li><a href="#_more_examples">24. More examples</a></li>
778<li><a href="#_mailing_list">25. Mailing list</a></li>
779<li><a href="#_javadocs">26. Javadocs</a></li>
780<li><a href="#_license">27. License</a></li>
781<li><a href="#_download">28. Download</a></li>
782</ul>
783</div>
784</div>
785<div id="content">
786<div id="preamble">
787<div class="sectionbody">
788<div style="float:right">
789<div style="display:inline-block">
790  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
791  <input type="hidden" name="cmd" value="_donations">
792  <input type="hidden" name="business" value="cedric@beust.com">
793  <input type="hidden" name="lc" value="US">
794  <input type="hidden" name="item_name" value="Cedric Beust">
795  <input type="hidden" name="no_note" value="0">
796  <input type="hidden" name="currency_code" value="USD">
797  <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
798  <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
799  <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" hidden="" style="display: none !important;">
800  </form>
801</div>
802</div>
803<div class="paragraph">
804<p><em>"Because life is too short to parse command line parameters"</em></p>
805</div>
806</div>
807</div>
808<div class="sect1">
809<h2 id="_overview">1. Overview</h2>
810<div class="sectionbody">
811<div class="paragraph">
812<p>JCommander is a very small Java framework that makes it trivial to parse command line parameters.
813You annotate fields with descriptions of your options:</p>
814</div>
815<div class="listingblock">
816<div class="content">
817<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import com.beust.jcommander.Parameter;
818
819public class Args {
820  @Parameter
821  private List&lt;String&gt; parameters = new ArrayList&lt;&gt;();
822
823  @Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")
824  private Integer verbose = 1;
825
826  @Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
827  private String groups;
828
829  @Parameter(names = "-debug", description = "Debug mode")
830  private boolean debug = false;
831}</code></pre>
832</div>
833</div>
834<div class="paragraph">
835<p>and then you simply ask JCommander to parse:</p>
836</div>
837<div class="listingblock">
838<div class="content">
839<pre class="prettyprint highlight"><code class="language-java" data-lang="java">Args args = new Args();
840String[] argv = { "-log", "2", "-groups", "unit" };
841JCommander.newBuilder()
842  .addObject(args)
843  .build()
844  .parse(argv);
845
846Assert.assertEquals(jct.verbose.intValue(), 2);</code></pre>
847</div>
848</div>
849<div class="paragraph">
850<p>Here is another example:</p>
851</div>
852<div class="listingblock">
853<div class="content">
854<pre class="prettyprint highlight"><code class="language-java" data-lang="java">class Main {
855    @Parameter(names={"--length", "-l"})
856    int length;
857    @Parameter(names={"--pattern", "-p"})
858    int pattern;
859
860    public static void main(String ... argv) {
861        Main main = new Main();
862        JCommander.newBuilder()
863            .addObject(main)
864            .build()
865            .parse(argv);
866        main.run();
867    }
868
869    public void run() {
870        System.out.printf("%d %d", length, pattern);
871    }
872}</code></pre>
873</div>
874</div>
875<div class="listingblock">
876<div class="content">
877<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -l 512 --pattern 2
878512 2</code></pre>
879</div>
880</div>
881</div>
882</div>
883<div class="sect1">
884<h2 id="_types_of_options">2. Types of options</h2>
885<div class="sectionbody">
886<div class="paragraph">
887<p>The fields representing your parameters can be of any type. Basic types (<code>Integer</code>, <code>Boolean</code>, etc&#8230;&#8203;) are supported by default and you can write type converters to support any other type (<code>File</code>, etc&#8230;&#8203;).</p>
888</div>
889<div class="sect2">
890<h3 id="_boolean">2.1. Boolean</h3>
891<div class="paragraph">
892<p>When a Parameter annotation is found on a field of type <code>boolean</code> or <code>Boolean</code>, JCommander interprets it as an option with an arity of 0:</p>
893</div>
894<div class="listingblock">
895<div class="content">
896<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-debug", description = "Debug mode")
897private boolean debug = false;</code></pre>
898</div>
899</div>
900<div class="paragraph">
901<p>Such a parameter does not require any additional parameter on the command line and if it&#8217;s detected during parsing, the corresponding field will be set to true. If you want to define a boolean parameter that&#8217;s true by default, you can declare it as having an arity of 1. Users will then have to specify the value they want explicitly:</p>
902</div>
903<div class="listingblock">
904<div class="content">
905<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-debug", description = "Debug mode", arity = 1)
906private boolean debug = true;</code></pre>
907</div>
908</div>
909<div class="paragraph">
910<p>Invoke with either of:</p>
911</div>
912<div class="listingblock">
913<div class="content">
914<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">program -debug true
915program -debug false</code></pre>
916</div>
917</div>
918<div class="paragraph">
919<p>When a Parameter annotation is found on a field of type <code>String</code>, <code>Integer</code>, <code>int</code>, <code>Long</code> or <code>long</code>, JCommander will parse the following parameter and it will attempt to cast it to the right type:</p>
920</div>
921<div class="listingblock">
922<div class="content">
923<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-log", description = "Level of verbosity")
924private Integer verbose = 1;</code></pre>
925</div>
926</div>
927<div class="listingblock">
928<div class="content">
929<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">java Main -log 3</code></pre>
930</div>
931</div>
932<div class="paragraph">
933<p>will cause the field verbose to receive the value 3. However:</p>
934</div>
935<div class="listingblock">
936<div class="content">
937<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -log test</code></pre>
938</div>
939</div>
940<div class="paragraph">
941<p>will cause an exception to be thrown.</p>
942</div>
943</div>
944<div class="sect2">
945<h3 id="_lists">2.2. Lists</h3>
946<div class="paragraph">
947<p>When a Parameter annotation is found on a field of type <code>List</code>, JCommander will interpret it as an option that can occur multiple times:</p>
948</div>
949<div class="listingblock">
950<div class="content">
951<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-host", description = "The host")
952private List&lt;String&gt; hosts = new ArrayList&lt;&gt;();</code></pre>
953</div>
954</div>
955<div class="paragraph">
956<p>will allow you to parse the following command line:</p>
957</div>
958<div class="listingblock">
959<div class="content">
960<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -host host1 -verbose -host host2</code></pre>
961</div>
962</div>
963<div class="paragraph">
964<p>When JCommander is done parsing the line above, the field hosts will contain the strings <code>"host1"</code> and <code>"host2"</code>.</p>
965</div>
966</div>
967<div class="sect2">
968<h3 id="_password">2.3. Password</h3>
969<div class="paragraph">
970<p>If one of your parameters is a password or some other value that you do not wish to appear in your history or in clear, you can declare it of type password and JCommander will then ask you to enter it in the console:</p>
971</div>
972<div class="listingblock">
973<div class="content">
974<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class ArgsPassword {
975  @Parameter(names = "-password", description = "Connection password", password = true)
976  private String password;
977}</code></pre>
978</div>
979</div>
980<div class="paragraph">
981<p>When you run your program, you will get the following prompt:</p>
982</div>
983<div class="listingblock">
984<div class="content">
985<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">Value for -password (Connection password):</code></pre>
986</div>
987</div>
988<div class="paragraph">
989<p>You will need to type the value at this point before JCommander resumes.</p>
990</div>
991</div>
992<div class="sect2">
993<h3 id="_echo_input">2.4. Echo Input</h3>
994<div class="paragraph">
995<p>In Java 6, by default, you will not be able to see what you type for passwords entered at the prompt (Java 5 and lower will always show the password). However, you can override this by setting echoInput to <code>true</code> (default is <code>false</code> and this setting only has an effect when password is <code>true</code>):</p>
996</div>
997<div class="listingblock">
998<div class="content">
999<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class ArgsPassword {
1000  @Parameter(names = "-password", description = "Connection password", password = true, echoInput = true)
1001  private String password;
1002}</code></pre>
1003</div>
1004</div>
1005</div>
1006</div>
1007</div>
1008<div class="sect1">
1009<h2 id="_custom_types_converters_and_splitters">3. Custom types (converters and splitters)</h2>
1010<div class="sectionbody">
1011<div class="paragraph">
1012<p>To bind parameters to custom types or change the way how JCommander splits parameters (default is to split via comma) JCommander provides two
1013interfaces <code>IStringConverter</code> and <code>IParameterSplitter</code>.</p>
1014</div>
1015<div class="sect2">
1016<h3 id="single-value">3.1. Custom types - Single value</h3>
1017<div class="paragraph">
1018<p>Use either the <code>converter=</code> attribute of the <code>@Parameter</code> or implement <code>IStringConverterFactory</code>.</p>
1019</div>
1020<div class="sect3">
1021<h4 id="_by_annotation">3.1.1. By annotation</h4>
1022<div class="paragraph">
1023<p>By default, JCommander parses the command line into basic types only (strings, booleans, integers and longs). Very often, your application actually needs more complex types (such as files, host names, lists, etc.). To achieve this, you can write a type converter by implementing the following interface:</p>
1024</div>
1025<div class="listingblock">
1026<div class="content">
1027<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface IStringConverter&lt;T&gt; {
1028  T convert(String value);
1029}</code></pre>
1030</div>
1031</div>
1032<div class="paragraph">
1033<p>For example, here is a converter that turns a string into a File:</p>
1034</div>
1035<div class="listingblock">
1036<div class="content">
1037<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class FileConverter implements IStringConverter&lt;File&gt; {
1038  @Override
1039  public File convert(String value) {
1040    return new File(value);
1041  }
1042}</code></pre>
1043</div>
1044</div>
1045<div class="paragraph">
1046<p>Then, all you need to do is declare your field with the correct type and specify the converter as an attribute:</p>
1047</div>
1048<div class="listingblock">
1049<div class="content">
1050<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-file", converter = FileConverter.class)
1051File file;</code></pre>
1052</div>
1053</div>
1054<div class="paragraph">
1055<p>JCommander ships with a few common converters (for more info please see the implementations of <code>IStringConverter</code>).</p>
1056</div>
1057<div class="sect4">
1058<h5 id="_note">Note</h5>
1059<div class="paragraph">
1060<p>If a converter is used for a <code>List</code> field:</p>
1061</div>
1062<div class="listingblock">
1063<div class="content">
1064<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-files", converter = FileConverter.class)
1065List&lt;File&gt; files;</code></pre>
1066</div>
1067</div>
1068<div class="paragraph">
1069<p>And the application is called as follows:</p>
1070</div>
1071<div class="listingblock">
1072<div class="content">
1073<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java App -files file1,file2,file3</code></pre>
1074</div>
1075</div>
1076<div class="paragraph">
1077<p>JCommander will split the string <code>file1,file2,file3</code> into <code>file1</code>, <code>file2</code>, <code>file3</code> and feed it one by one to the converter.</p>
1078</div>
1079<div class="paragraph">
1080<p>For an alternative solution to parse a list of values, see <a href="#list-value">Custom types - List value</a>.</p>
1081</div>
1082</div>
1083</div>
1084<div class="sect3">
1085<h4 id="_by_factory">3.1.2. By factory</h4>
1086<div class="paragraph">
1087<p>If the custom types you use appear multiple times in your application, having to specify the converter in each annotation can become tedious. To address this, you can use an <code>IStringConverterFactory</code>:</p>
1088</div>
1089<div class="listingblock">
1090<div class="content">
1091<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface IStringConverterFactory {
1092  &lt;T&gt; Class&lt;? extends IStringConverter&lt;T&gt;&gt; getConverter(Class&lt;T&gt; forType);
1093}</code></pre>
1094</div>
1095</div>
1096<div class="paragraph">
1097<p>For example, suppose you need to parse a string representing a host and a port:</p>
1098</div>
1099<div class="listingblock">
1100<div class="content">
1101<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java App -target example.com:8080</code></pre>
1102</div>
1103</div>
1104<div class="paragraph">
1105<p>You define the holder class :</p>
1106</div>
1107<div class="listingblock">
1108<div class="content">
1109<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class HostPort {
1110  public HostPort(String host, String port) {
1111     this.host = host;
1112     this.port = port;
1113  }
1114
1115  final String host;
1116  final Integer port;
1117}</code></pre>
1118</div>
1119</div>
1120<div class="paragraph">
1121<p>and the string converter to create instances of this class:</p>
1122</div>
1123<div class="listingblock">
1124<div class="content">
1125<pre class="prettyprint highlight"><code class="language-java" data-lang="java">class HostPortConverter implements IStringConverter&lt;HostPort&gt; {
1126  @Override
1127  public HostPort convert(String value) {
1128    String[] s = value.split(":");
1129    return new HostPort(s[0], Integer.parseInt(s[1]));
1130  }
1131}</code></pre>
1132</div>
1133</div>
1134<div class="paragraph">
1135<p>The factory is straightforward:</p>
1136</div>
1137<div class="listingblock">
1138<div class="content">
1139<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class Factory implements IStringConverterFactory {
1140  public Class&lt;? extends IStringConverter&lt;?&gt;&gt; getConverter(Class forType) {
1141    if (forType.equals(HostPort.class)) return HostPortConverter.class;
1142    else return null;
1143  }</code></pre>
1144</div>
1145</div>
1146<div class="paragraph">
1147<p>You can now use the type <code>HostPort</code> as a parameter without any converterClass attribute:</p>
1148</div>
1149<div class="listingblock">
1150<div class="content">
1151<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class ArgsConverterFactory {
1152  @Parameter(names = "-hostport")
1153  private HostPort hostPort;
1154}</code></pre>
1155</div>
1156</div>
1157<div class="paragraph">
1158<p>All you need to do is add the factory to your JCommander object:</p>
1159</div>
1160<div class="listingblock">
1161<div class="content">
1162<pre class="prettyprint highlight"><code class="language-java" data-lang="java">ArgsConverterFactory a = new ArgsConverterFactory();
1163JCommander jc = JCommander.newBuilder()
1164    .addObject(a)
1165    .addConverterFactory(new Factory())
1166    .build()
1167    .parse("-hostport", "example.com:8080");
1168
1169Assert.assertEquals(a.hostPort.host, "example.com");
1170Assert.assertEquals(a.hostPort.port.intValue(), 8080);</code></pre>
1171</div>
1172</div>
1173<div class="paragraph">
1174<p>Another advantage of using string converter factories is that your factories can come from a dependency injection framework.</p>
1175</div>
1176</div>
1177</div>
1178<div class="sect2">
1179<h3 id="list-value">3.2. Custom types - List value</h3>
1180<div class="paragraph">
1181<p>Use the <code>listConverter=</code> attribute of the <code>@Parameter</code> annotation and assign a custom <code>IStringConverter</code> implementation to convert a <code>String</code> into a <code>List</code> of values.</p>
1182</div>
1183<div class="sect3">
1184<h4 id="_by_annotation_2">3.2.1. By annotation</h4>
1185<div class="paragraph">
1186<p>If your application needs a list of complex types, write a list type converter by implementing the same interface as before:</p>
1187</div>
1188<div class="listingblock">
1189<div class="content">
1190<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface IStringConverter&lt;T&gt; {
1191  T convert(String value);
1192}</code></pre>
1193</div>
1194</div>
1195<div class="paragraph">
1196<p>where <code>T</code> is a <code>List</code>.</p>
1197</div>
1198<div class="paragraph">
1199<p>For example, here is a list converter that turns a string into a <code>List&lt;File&gt;</code>:</p>
1200</div>
1201<div class="listingblock">
1202<div class="content">
1203<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class FileListConverter implements IStringConverter&lt;List&lt;File&gt;&gt; {
1204  @Override
1205  public List&lt;File&gt; convert(String files) {
1206    String [] paths = files.split(",");
1207    List&lt;File&gt; fileList = new ArrayList&lt;&gt;();
1208    for(String path : paths){
1209        fileList.add(new File(path));
1210    }
1211    return fileList;
1212  }
1213}</code></pre>
1214</div>
1215</div>
1216<div class="paragraph">
1217<p>Then, all you need to do is declare your field with the correct type and specify the list converter as an attribute:</p>
1218</div>
1219<div class="listingblock">
1220<div class="content">
1221<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-files", listConverter = FileListConverter.class)
1222List&lt;File&gt; file;</code></pre>
1223</div>
1224</div>
1225<div class="paragraph">
1226<p>Now if you call for application as in the following example:</p>
1227</div>
1228<div class="listingblock">
1229<div class="content">
1230<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java App -files file1,file2,file3</code></pre>
1231</div>
1232</div>
1233<div class="paragraph">
1234<p>The parameter <code>file1,file2,file3</code> is given to the <code>listConverter</code> and will the properly processed.</p>
1235</div>
1236<div class="paragraph">
1237<p>JCommander ships with a default converter for <code>String</code> values.</p>
1238</div>
1239</div>
1240</div>
1241<div class="sect2">
1242<h3 id="_splitting">3.3. Splitting</h3>
1243<div class="paragraph">
1244<p>Use the <code>splitter=</code> attribute of the <code>@Parameter</code> annotation and assign a custom <code>IParameterSplitter</code> implementation to handle how parameters are split in sub-parts.</p>
1245</div>
1246<div class="sect3">
1247<h4 id="_by_annotation_3">3.3.1. By annotation</h4>
1248<div class="paragraph">
1249<p>By default, JCommander tries to split parameters for <code>List</code> field types on commas.</p>
1250</div>
1251<div class="paragraph">
1252<p>To split parameters on other characters, you can write a custom splitter by implementing the following interface:</p>
1253</div>
1254<div class="listingblock">
1255<div class="content">
1256<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface IParameterSplitter {
1257  List&lt;String&gt; split(String value);
1258}</code></pre>
1259</div>
1260</div>
1261<div class="paragraph">
1262<p>For example, here is a splitter that splits a string on semicolon:</p>
1263</div>
1264<div class="listingblock">
1265<div class="content">
1266<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public static class SemiColonSplitter implements IParameterSplitter {
1267    public List&lt;String&gt; split(String value) {
1268      return Arrays.asList(value.split(";"));
1269    }
1270}</code></pre>
1271</div>
1272</div>
1273<div class="paragraph">
1274<p>Then, all you need to do is declare your field with the correct type and specify the splitter as an attribute:</p>
1275</div>
1276<div class="listingblock">
1277<div class="content">
1278<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-files", converter = FileConverter.class, splitter = SemiColonSplitter.class)
1279List&lt;File&gt; files;</code></pre>
1280</div>
1281</div>
1282<div class="paragraph">
1283<p>JCommander will split the string <code>file1;file2;file3</code> into <code>file1</code>, <code>file2</code>, <code>file3</code> and feed it one by one to the converter.</p>
1284</div>
1285</div>
1286</div>
1287</div>
1288</div>
1289<div class="sect1">
1290<h2 id="_parameter_validation">4. Parameter validation</h2>
1291<div class="sectionbody">
1292<div class="paragraph">
1293<p>Parameter validation can be performed in two different ways: at the individual parameter level or globally.</p>
1294</div>
1295<div class="sect2">
1296<h3 id="_individual_parameter_validation">4.1. Individual parameter validation</h3>
1297<div class="paragraph">
1298<p>You can ask JCommander to perform early validation on your parameters by providing a class that implements the following interface:</p>
1299</div>
1300<div class="listingblock">
1301<div class="content">
1302<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface IParameterValidator {
1303 /**
1304   * Validate the parameter.
1305   *
1306   * @param name The name of the parameter (e.g. "-host").
1307   * @param value The value of the parameter that we need to validate
1308   *
1309   * @throws ParameterException Thrown if the value of the parameter is invalid.
1310   */
1311  void validate(String name, String value) throws ParameterException;
1312}</code></pre>
1313</div>
1314</div>
1315<div class="paragraph">
1316<p>Here is an example implementation that will make sure that the parameter is a positive integer:</p>
1317</div>
1318<div class="listingblock">
1319<div class="content">
1320<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class PositiveInteger implements IParameterValidator {
1321 public void validate(String name, String value)
1322      throws ParameterException {
1323    int n = Integer.parseInt(value);
1324    if (n &lt; 0) {
1325      throw new ParameterException("Parameter " + name + " should be positive (found " + value +")");
1326    }
1327  }
1328}</code></pre>
1329</div>
1330</div>
1331<div class="paragraph">
1332<p>Specify the name of a class implementing this interface in the <code>validateWith</code> attribute of your <code>@Parameter</code> annotations:</p>
1333</div>
1334<div class="listingblock">
1335<div class="content">
1336<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-age", validateWith = PositiveInteger.class)
1337private Integer age;</code></pre>
1338</div>
1339</div>
1340<div class="paragraph">
1341<p>Attempting to pass a negative integer to this option will cause a ParameterException to be thrown.</p>
1342</div>
1343<div class="paragraph">
1344<p>Multiple validators may be specified:</p>
1345</div>
1346<div class="listingblock">
1347<div class="content">
1348<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-count", validateWith = { PositiveInteger.class, CustomOddNumberValidator.class })
1349private Integer value;</code></pre>
1350</div>
1351</div>
1352</div>
1353<div class="sect2">
1354<h3 id="_global_parameter_validation">4.2. Global parameter validation</h3>
1355<div class="paragraph">
1356<p>After parsing your parameters with JCommander, you might want to perform additional validation across these parameters, such as making sure that two mutually exclusive parameters are not both specified. Because of all the potential combinations involved in such validation, JCommander does not provide any annotation-based solution to perform this validation because such an approach would necessarily be very limited by the very nature of Java annotations. Instead, you should simply perform this validation in Java on all the arguments that JCommander just parsed.</p>
1357</div>
1358</div>
1359</div>
1360</div>
1361<div class="sect1">
1362<h2 id="_main_parameter">5. Main parameter</h2>
1363<div class="sectionbody">
1364<div class="paragraph">
1365<p>So far, all the <code>@Parameter</code> annotations we have seen had defined an attribute called <code>names</code>. You can define one (and at most one) parameter without any such attribute. This parameter needs to be a <code>List&lt;String&gt;</code> and it will contain all the parameters that are not options:</p>
1366</div>
1367<div class="listingblock">
1368<div class="content">
1369<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(description = "Files")
1370private List&lt;String&gt; files = new ArrayList&lt;&gt;();
1371
1372@Parameter(names = "-debug", description = "Debugging level")
1373private Integer debug = 1;</code></pre>
1374</div>
1375</div>
1376<div class="paragraph">
1377<p>will allow you to parse:</p>
1378</div>
1379<div class="listingblock">
1380<div class="content">
1381<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -debug file1 file2</code></pre>
1382</div>
1383</div>
1384<div class="paragraph">
1385<p>and the field files will receive the strings <code>"file1"</code> and <code>"file2"</code>.</p>
1386</div>
1387</div>
1388</div>
1389<div class="sect1">
1390<h2 id="_private_parameters">6. Private parameters</h2>
1391<div class="sectionbody">
1392<div class="paragraph">
1393<p>Parameters can be private:</p>
1394</div>
1395<div class="listingblock">
1396<div class="content">
1397<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class ArgsPrivate {
1398  @Parameter(names = "-verbose")
1399  private Integer verbose = 1;
1400
1401  public Integer getVerbose() {
1402    return verbose;
1403  }
1404}
1405ArgsPrivate args = new ArgsPrivate();
1406JCommander.newBuilder()
1407    .addObject(args)
1408    .build()
1409    .parse("-verbose", "3");
1410Assert.assertEquals(args.getVerbose().intValue(), 3);</code></pre>
1411</div>
1412</div>
1413</div>
1414</div>
1415<div class="sect1">
1416<h2 id="_parameter_separators">7. Parameter separators</h2>
1417<div class="sectionbody">
1418<div class="paragraph">
1419<p>By default, parameters are separated by spaces, but you can change this setting to allow different separators:</p>
1420</div>
1421<div class="listingblock">
1422<div class="content">
1423<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -log:3</code></pre>
1424</div>
1425</div>
1426<div class="paragraph">
1427<p>or</p>
1428</div>
1429<div class="listingblock">
1430<div class="content">
1431<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -level=42</code></pre>
1432</div>
1433</div>
1434<div class="paragraph">
1435<p>You define the separator with the @Parameters annotation:</p>
1436</div>
1437<div class="listingblock">
1438<div class="content">
1439<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameters(separators = "=")
1440public class SeparatorEqual {
1441  @Parameter(names = "-level")
1442  private Integer level = 2;
1443}</code></pre>
1444</div>
1445</div>
1446</div>
1447</div>
1448<div class="sect1">
1449<h2 id="_multiple_descriptions">8. Multiple descriptions</h2>
1450<div class="sectionbody">
1451<div class="paragraph">
1452<p>You can spread the description of your parameters on more than one class. For example, you can define the following two classes:</p>
1453</div>
1454<div class="listingblock">
1455<div class="content">
1456<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class ArgsMaster {
1457  @Parameter(names = "-master")
1458  private String master;
1459}
1460
1461public class ArgsSlave {
1462  @Parameter(names = "-slave")
1463  private String slave;
1464}</code></pre>
1465</div>
1466</div>
1467<div class="paragraph">
1468<p>and pass these two objects to JCommander:</p>
1469</div>
1470<div class="listingblock">
1471<div class="content">
1472<pre class="prettyprint highlight"><code class="language-java" data-lang="java">ArgsMaster m = new ArgsMaster();
1473ArgsSlave s = new ArgsSlave();
1474String[] argv = { "-master", "master", "-slave", "slave" };
1475JCommander.newBuilder()
1476    .addObject(new Object[] { m , s })
1477    .build()
1478    .parse(argv);
1479
1480Assert.assertEquals(m.master, "master");
1481Assert.assertEquals(s.slave, "slave");</code></pre>
1482</div>
1483</div>
1484</div>
1485</div>
1486<div class="sect1">
1487<h2 id="__syntax">9. @ syntax</h2>
1488<div class="sectionbody">
1489<div class="paragraph">
1490<p>JCommander supports the @ syntax, which allows you to put all your options into a file and pass this file as parameter:</p>
1491</div>
1492<div id="app-listing" class="listingblock">
1493<div class="title">/tmp/parameters</div>
1494<div class="content">
1495<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">-verbose
1496file1
1497file2
1498file3</code></pre>
1499</div>
1500</div>
1501<div class="listingblock">
1502<div class="content">
1503<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main @/tmp/parameters</code></pre>
1504</div>
1505</div>
1506</div>
1507</div>
1508<div class="sect1">
1509<h2 id="_arities_multiple_values_for_parameters">10. Arities (multiple values for parameters)</h2>
1510<div class="sectionbody">
1511<div class="sect2">
1512<h3 id="_fixed_arities">10.1. Fixed arities</h3>
1513<div class="paragraph">
1514<p>If some of your parameters require more than one value, such as the following example where two values are expected after -pairs:</p>
1515</div>
1516<div class="listingblock">
1517<div class="content">
1518<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -pairs slave master foo.xml</code></pre>
1519</div>
1520</div>
1521<div class="paragraph">
1522<p>then you need to define your parameter with the arity attribute and make that parameter a <code>List&lt;String&gt;</code>:</p>
1523</div>
1524<div class="listingblock">
1525<div class="content">
1526<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-pairs", arity = 2, description = "Pairs")
1527private List&lt;String&gt; pairs;</code></pre>
1528</div>
1529</div>
1530<div class="paragraph">
1531<p>You don&#8217;t need to specify an arity for parameters of type <code>boolean</code> or <code>Boolean</code> (which have a default arity of 0) and of types <code>String</code>, <code>Integer</code>, <code>int</code>, <code>Long</code> and <code>long</code> (which have a default arity of 1).</p>
1532</div>
1533<div class="paragraph">
1534<p>Also, note that only <code>List&lt;String&gt;</code> is allowed for parameters that define an arity. You will have to convert these values yourself if the parameters you need are of type <code>Integer</code> or other (this limitation is due to Java&#8217;s erasure).</p>
1535</div>
1536</div>
1537<div class="sect2">
1538<h3 id="_variable_arities">10.2. Variable arities</h3>
1539<div class="paragraph">
1540<p>You can specify that a parameter can receive an indefinite number of parameters, up to the next option. For example:</p>
1541</div>
1542<div class="listingblock">
1543<div class="content">
1544<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">program -foo a1 a2 a3 -bar
1545program -foo a1 -bar</code></pre>
1546</div>
1547</div>
1548<div class="paragraph">
1549<p>Such a parameter can be parsed in two different ways.</p>
1550</div>
1551<div class="sect3">
1552<h4 id="_with_a_list">10.2.1. With a list</h4>
1553<div class="paragraph">
1554<p>If the number of following parameters is unknown, your parameter must be of type <code>List&lt;String&gt;</code> and you
1555need to set the boolean <code>variableArity</code> to <code>true</code>:</p>
1556</div>
1557<div class="listingblock">
1558<div class="content">
1559<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-foo", variableArity = true)
1560public List&lt;String&gt; foo = new ArrayList&lt;&gt;();</code></pre>
1561</div>
1562</div>
1563</div>
1564<div class="sect3">
1565<h4 id="_with_a_class">10.2.2. With a class</h4>
1566<div class="paragraph">
1567<p>Alternatively, you can define a class in which the following parameters will be stored, based on their order
1568of appearance:</p>
1569</div>
1570<div class="listingblock">
1571<div class="content">
1572<pre class="prettyprint highlight"><code class="language-java" data-lang="java">static class MvParameters {
1573  @SubParameter(order = 0)
1574  String from;
1575
1576  @SubParameter(order = 1)
1577  String to;
1578}
1579
1580@Test
1581public void arity() {
1582  class Parameters {
1583    @Parameter(names = {"--mv"}, arity = 2)
1584    private MvParameters mvParameters;
1585  }
1586
1587  Parameters args = new Parameters();
1588  JCommander.newBuilder()
1589          .addObject(args)
1590          .args(new String[]{"--mv", "from", "to"})
1591          .build();
1592
1593  Assert.assertNotNull(args.mvParameters);
1594  Assert.assertEquals(args.mvParameters.from, "from");
1595  Assert.assertEquals(args.mvParameters.to, "to");
1596}</code></pre>
1597</div>
1598</div>
1599</div>
1600</div>
1601</div>
1602</div>
1603<div class="sect1">
1604<h2 id="_multiple_option_names">11. Multiple option names</h2>
1605<div class="sectionbody">
1606<div class="paragraph">
1607<p>You can specify more than one option name:</p>
1608</div>
1609<div class="listingblock">
1610<div class="content">
1611<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = { "-d", "--outputDirectory" }, description = "Directory")
1612private String outputDirectory;</code></pre>
1613</div>
1614</div>
1615<div class="paragraph">
1616<p>will allow both following syntaxes:</p>
1617</div>
1618<div class="listingblock">
1619<div class="content">
1620<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ java Main -d /tmp
1621$ java Main --outputDirectory /tmp</code></pre>
1622</div>
1623</div>
1624</div>
1625</div>
1626<div class="sect1">
1627<h2 id="_other_option_configurations">12. Other option configurations</h2>
1628<div class="sectionbody">
1629<div class="paragraph">
1630<p>You can configure how options are looked up in a few different ways:</p>
1631</div>
1632<div class="ulist">
1633<ul>
1634<li>
1635<p><code>JCommander#setCaseSensitiveOptions(boolean)</code>: specify whether options are case sensitive. If you call this method with <code>false</code>, then <code>"-param"</code> and <code>"-PARAM"</code> are considered equal.</p>
1636</li>
1637<li>
1638<p><code>JCommander#setAllowAbbreviatedOptions(boolean)</code>: specify whether users can pass abbreviated options. If you call this method with <code>true</code> then users can pass <code>"-par"</code> to specify an option called <code>-param</code>. JCommander will throw a <code>ParameterException</code> if the abbreviated name is ambiguous.</p>
1639</li>
1640</ul>
1641</div>
1642</div>
1643</div>
1644<div class="sect1">
1645<h2 id="_required_and_optional_parameters">13. Required and optional parameters</h2>
1646<div class="sectionbody">
1647<div class="paragraph">
1648<p>If some of your parameters are mandatory, you can use the <code>required</code> attribute (which default to <code>false</code>):</p>
1649</div>
1650<div class="listingblock">
1651<div class="content">
1652<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-host", required = true)
1653private String host;</code></pre>
1654</div>
1655</div>
1656<div class="paragraph">
1657<p>If this parameter is not specified, JCommander will throw an exception telling you which options are missing.</p>
1658</div>
1659</div>
1660</div>
1661<div class="sect1">
1662<h2 id="_default_values">14. Default values</h2>
1663<div class="sectionbody">
1664<div class="paragraph">
1665<p>The most common way to specify a default value for your parameters is to initialize the field at declaration time:</p>
1666</div>
1667<div class="listingblock">
1668<div class="content">
1669<pre class="prettyprint highlight"><code class="language-java" data-lang="java">private Integer logLevel = 3;</code></pre>
1670</div>
1671</div>
1672<div class="paragraph">
1673<p>For more complicated cases, you might want to be able to reuse identical default values across several main classes or be able to specify these default values in a centralized location such as a <code>.properties</code> or an XML file. In this case, you can use an <code>IDefaultProvider</code>:</p>
1674</div>
1675<div class="listingblock">
1676<div class="content">
1677<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface IDefaultProvider {
1678  /**
1679   * @param optionName The name of the option as specified in the names() attribute
1680   * of the @Parameter option (e.g. "-file").
1681   *
1682   * @return the default value for this option.
1683   */
1684  String getDefaultValueFor(String optionName);
1685}</code></pre>
1686</div>
1687</div>
1688<div class="paragraph">
1689<p>By passing an implementation of this interface to your JCommander object, you can now control which default value will be used for your options. Note that the value returned by this method will then be passed to a string converter, if any is applicable, thereby allowing you to specify default values for any types you need.</p>
1690</div>
1691<div class="paragraph">
1692<p>For example, here is a default provider that will assign a default value of 42 for all your parameters except <code>"-debug"</code>:</p>
1693</div>
1694<div class="listingblock">
1695<div class="content">
1696<pre class="prettyprint highlight"><code class="language-java" data-lang="java">private static final IDefaultProvider DEFAULT_PROVIDER = new IDefaultProvider() {
1697  @Override
1698  public String getDefaultValueFor(String optionName) {
1699    return "-debug".equals(optionName) ? "false" : "42";
1700  }
1701};
1702
1703// ...
1704
1705JCommander jc = JCommander.newBuilder()
1706    .addObject(new Args())
1707    .defaultProvider(DEFAULT_PROVIDER)
1708    .build()</code></pre>
1709</div>
1710</div>
1711</div>
1712</div>
1713<div class="sect1">
1714<h2 id="_help_parameter">15. Help parameter</h2>
1715<div class="sectionbody">
1716<div class="paragraph">
1717<p>If one of your parameters is used to display some help or usage, you need use the help attribute:</p>
1718</div>
1719<div class="listingblock">
1720<div class="content">
1721<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "--help", help = true)
1722private boolean help;</code></pre>
1723</div>
1724</div>
1725<div class="paragraph">
1726<p>If you omit this boolean, JCommander will instead issue an error message when it tries to validate your command and it finds that you didn&#8217;t specify some of the required parameters.</p>
1727</div>
1728</div>
1729</div>
1730<div class="sect1">
1731<h2 id="_more_complex_syntaxes_commands">16. More complex syntaxes (commands)</h2>
1732<div class="sectionbody">
1733<div class="paragraph">
1734<p>Complex tools such as <code>git</code> or <code>svn</code> understand a whole set of commands, each of which with their own specific syntax:</p>
1735</div>
1736<div class="listingblock">
1737<div class="content">
1738<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">$ git commit --amend -m "Bug fix"</code></pre>
1739</div>
1740</div>
1741<div class="paragraph">
1742<p>Words such as <code>"commit"</code> above are called "commands" in JCommander, and you can specify them by creating one arg object per command:</p>
1743</div>
1744<div class="listingblock">
1745<div class="content">
1746<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameters(separators = "=", commandDescription = "Record changes to the repository")
1747private class CommandCommit {
1748
1749  @Parameter(description = "The list of files to commit")
1750  private List&lt;String&gt; files;
1751
1752  @Parameter(names = "--amend", description = "Amend")
1753  private Boolean amend = false;
1754
1755  @Parameter(names = "--author")
1756  private String author;
1757}
1758
1759@Parameters(commandDescription = "Add file contents to the index")
1760public class CommandAdd {
1761
1762  @Parameter(description = "File patterns to add to the index")
1763  private List&lt;String&gt; patterns;
1764
1765  @Parameter(names = "-i")
1766  private Boolean interactive = false;
1767}</code></pre>
1768</div>
1769</div>
1770<div class="paragraph">
1771<p>Then you register these commands with your JCommander object. After the parsing phase, you call <code>getParsedCommand()</code> on your JCommander object, and based on the command that is returned, you know which arg object to inspect (you can still use a main arg object if you want to support options before the first command appears on the command line):</p>
1772</div>
1773<div class="listingblock">
1774<div class="content">
1775<pre class="prettyprint highlight"><code class="language-java" data-lang="java">CommandMain cm = new CommandMain();
1776CommandAdd add = new CommandAdd();
1777CommandCommit commit = new CommandCommit();
1778JCommander jc = JCommander.newBuilder()
1779    .addObject(cm)
1780    .addCommand("add", add);
1781    .addCommand("commit", commit);
1782    .build();
1783
1784jc.parse("-v", "commit", "--amend", "--author=cbeust", "A.java", "B.java");
1785
1786Assert.assertTrue(cm.verbose);
1787Assert.assertEquals(jc.getParsedCommand(), "commit");
1788Assert.assertTrue(commit.amend);
1789Assert.assertEquals(commit.author, "cbeust");
1790Assert.assertEquals(commit.files, Arrays.asList("A.java", "B.java"));</code></pre>
1791</div>
1792</div>
1793</div>
1794</div>
1795<div class="sect1">
1796<h2 id="_exception">17. Exception</h2>
1797<div class="sectionbody">
1798<div class="paragraph">
1799<p>Whenever JCommander detects an error, it will throw a <code>ParameterException</code>. Note that this is a Runtime Exception, since your application is probably not initialized correctly at this point. Also, <code>ParameterException</code> contains the
1800<code>JCommander</code> instance and you can also invoke <code>usage()</code> on it if you need to display some help.</p>
1801</div>
1802</div>
1803</div>
1804<div class="sect1">
1805<h2 id="_usage">18. Usage</h2>
1806<div class="sectionbody">
1807<div class="paragraph">
1808<p>You can invoke <code>usage()</code> on the JCommander instance that you used to parse your command line in order to generate a summary of all the options that your program understands:</p>
1809</div>
1810<div class="listingblock">
1811<div class="content">
1812<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">Usage: &lt;main class&gt; [options]
1813  Options:
1814    -debug          Debug mode (default: false)
1815    -groups         Comma-separated list of group names to be run
1816  * -log, -verbose  Level of verbosity (default: 1)
1817    -long           A long number (default: 0)</code></pre>
1818</div>
1819</div>
1820<div class="paragraph">
1821<p>You can customize the name of your program by calling <code>setProgramName()</code> on your JCommander object. Options preceded by an asterisk are required.</p>
1822</div>
1823<div class="paragraph">
1824<p>You can also specify the order in which each option should be displayed when calling <code>usage()</code> by setting the <code>order</code> attribute of the <code>@Parameter</code> annotation:</p>
1825</div>
1826<div class="listingblock">
1827<div class="content">
1828<pre class="prettyprint highlight"><code class="language-java" data-lang="java">class Parameters {
1829    @Parameter(names = "--importantOption", order = 0)
1830    private boolean a;
1831
1832    @Parameter(names = "--lessImportantOption", order = 3)
1833    private boolean b;</code></pre>
1834</div>
1835</div>
1836</div>
1837</div>
1838<div class="sect1">
1839<h2 id="_hiding_parameters">19. Hiding parameters</h2>
1840<div class="sectionbody">
1841<div class="paragraph">
1842<p>If you don&#8217;t want certain parameters to appear in the usage, you can mark them as "hidden":</p>
1843</div>
1844<div class="listingblock">
1845<div class="content">
1846<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameter(names = "-debug", description = "Debug mode", hidden = true)
1847private boolean debug = false;</code></pre>
1848</div>
1849</div>
1850</div>
1851</div>
1852<div class="sect1">
1853<h2 id="_internationalization">20. Internationalization</h2>
1854<div class="sectionbody">
1855<div class="paragraph">
1856<p>You can internationalize the descriptions of your parameters. First you use the <code>@Parameters</code> annotation at the top of your class to define the name of your message bundle, and then you use the <code>descriptionKey</code> attribute instead of description on all the <code>@Parameters</code> that require translations. This <code>descriptionKey</code> is the key to the string into your message bundle:</p>
1857</div>
1858<div class="listingblock">
1859<div class="content">
1860<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Parameters(resourceBundle = "MessageBundle")
1861private class ArgsI18N2 {
1862  @Parameter(names = "-host", description = "Host", descriptionKey = "host")
1863  String hostName;
1864}</code></pre>
1865</div>
1866</div>
1867<div class="paragraph">
1868<p>Your bundle needs to define this key:</p>
1869</div>
1870<div class="listingblock">
1871<div class="content">
1872<pre class="prettyprint highlight"><code class="language-bash" data-lang="bash">host: Hôte</code></pre>
1873</div>
1874</div>
1875<div class="paragraph">
1876<p>JCommander will then use the default locale to resolve your descriptions.</p>
1877</div>
1878</div>
1879</div>
1880<div class="sect1">
1881<h2 id="_parameter_delegates">21. Parameter delegates</h2>
1882<div class="sectionbody">
1883<div class="paragraph">
1884<p>If you are writing many different tools in the same project, you will probably find that most of these tools can share configurations. While you can use inheritance with your objects to avoid repeating this code, the restriction to single inheritance of implementation might limit your flexibility. To address this problem, JCommander supports parameter delegates.</p>
1885</div>
1886<div class="paragraph">
1887<p>When JCommander encounters an object annotated with <code>@ParameterDelegate</code> in one of your objects, it acts as if this object had been added as a description object itself:</p>
1888</div>
1889<div class="listingblock">
1890<div class="content">
1891<pre class="prettyprint highlight"><code class="language-java" data-lang="java">class Delegate {
1892  @Parameter(names = "-port")
1893  private int port;
1894}
1895
1896class MainParams {
1897  @Parameter(names = "-v")
1898  private boolean verbose;
1899
1900  @ParametersDelegate
1901  private Delegate delegate = new Delegate();
1902}</code></pre>
1903</div>
1904</div>
1905<div class="paragraph">
1906<p>The example above specifies a delegate parameter Delegate which is then referenced in MainParams. You only need to add a <code>MainParams</code> object to your
1907JCommander configuration in order to use the delegate:</p>
1908</div>
1909<div class="listingblock">
1910<div class="content">
1911<pre class="prettyprint highlight"><code class="language-java" data-lang="java">MainParams p = new MainParams();
1912JCommander.newBuilder().addObject(p).build()
1913    .parse("-v", "-port", "1234");
1914Assert.assertTrue(p.isVerbose);
1915Assert.assertEquals(p.delegate.port, 1234);</code></pre>
1916</div>
1917</div>
1918</div>
1919</div>
1920<div class="sect1">
1921<h2 id="_dynamic_parameters">22. Dynamic parameters</h2>
1922<div class="sectionbody">
1923<div class="paragraph">
1924<p>JCommander allows you to specify parameters that are not known at compile time, such as "-Da=b -Dc=d". Such parameters are specified with the <code>@DynamicParameter</code> annotation and must be of type <code>Map&lt;String, String&gt;</code>. Dynamic parameters are allowed to appear multiple times on the command line:</p>
1925</div>
1926<div class="listingblock">
1927<div class="content">
1928<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@DynamicParameter(names = "-D", description = "Dynamic parameters go here")
1929private Map&lt;String, String&gt; params = new HashMap&lt;&gt;();</code></pre>
1930</div>
1931</div>
1932<div class="paragraph">
1933<p>You can specify a different assignment string than = by using the attribute assignment.</p>
1934</div>
1935</div>
1936</div>
1937<div class="sect1">
1938<h2 id="_jcommander_in_other_languages">23. JCommander in other languages</h2>
1939<div class="sectionbody">
1940<div class="sect2">
1941<h3 id="_kotlin">23.1. Kotlin</h3>
1942<div class="listingblock">
1943<div class="content">
1944<pre class="prettyprint highlight"><code class="language-kotlin" data-lang="kotlin">class Args {
1945    @Parameter
1946    var targets: List&lt;String&gt; = arrayListOf()
1947
1948    @Parameter(names = arrayOf("-bf", "--buildFile"), description = "The build file")
1949    var buildFile: String? = null
1950
1951    @Parameter(names = arrayOf("--checkVersions"),
1952               description = "Check if there are any newer versions of the dependencies")
1953    var checkVersions = false
1954}</code></pre>
1955</div>
1956</div>
1957</div>
1958<div class="sect2">
1959<h3 id="_groovy">23.2. Groovy</h3>
1960<div class="paragraph">
1961<p>Courtesy of Paul King:</p>
1962</div>
1963<div class="listingblock">
1964<div class="content">
1965<pre class="prettyprint highlight"><code class="language-groovy" data-lang="groovy">import com.beust.jcommander.*
1966
1967class Args {
1968  @Parameter(names = ["-f", "--file"], description = "File to load. Can be specified multiple times.")
1969  List&lt;String&gt; file
1970}
1971
1972new Args().with {
1973  JCommander.newBuilder().addObject(it).build().parse(argv)
1974  file.each { println "file: ${new File(it).name}" }
1975}</code></pre>
1976</div>
1977</div>
1978</div>
1979</div>
1980</div>
1981<div class="sect1">
1982<h2 id="_more_examples">24. More examples</h2>
1983<div class="sectionbody">
1984<div class="paragraph">
1985<p>Here are the description files for a few projects that use JCommander:</p>
1986</div>
1987<div class="ulist">
1988<ul>
1989<li>
1990<p><a href="https://github.com/cbeust/testng/blob/master/src/main/java/org/testng/CommandLineArgs.java">TestNG</a></p>
1991</li>
1992<li>
1993<p><a href="https://github.com/cbeust/kobalt/blob/master/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt">Kobalt</a></p>
1994</li>
1995</ul>
1996</div>
1997</div>
1998</div>
1999<div class="sect1">
2000<h2 id="_mailing_list">25. Mailing list</h2>
2001<div class="sectionbody">
2002<div class="paragraph">
2003<p>Join the <a href="http://groups.google.com/group/jcommander">JCommander Google group</a> if you are interested in discussions about JCommander.</p>
2004</div>
2005</div>
2006</div>
2007<div class="sect1">
2008<h2 id="_javadocs">26. Javadocs</h2>
2009<div class="sectionbody">
2010<div class="paragraph">
2011<p>The Javadocs for JCommander can be found <a href="http://jcommander.org/apidocs/">here</a>.</p>
2012</div>
2013</div>
2014</div>
2015<div class="sect1">
2016<h2 id="_license">27. License</h2>
2017<div class="sectionbody">
2018<div class="paragraph">
2019<p>JCommander is released under the <a href="https://github.com/cbeust/jcommander/blob/master/license.txt">Apache 2.0 license</a>.</p>
2020</div>
2021</div>
2022</div>
2023<div class="sect1">
2024<h2 id="_download">28. Download</h2>
2025<div class="sectionbody">
2026<div class="paragraph">
2027<p>You can download JCommander from the following locations:</p>
2028</div>
2029<div class="ulist">
2030<ul>
2031<li>
2032<p><a href="http://github.com/cbeust/jcommander">Source on github</a></p>
2033</li>
2034<li>
2035<p>Kobalt</p>
2036</li>
2037</ul>
2038</div>
2039<div class="listingblock">
2040<div class="content">
2041<pre class="prettyprint highlight"><code class="language-groovy" data-lang="groovy">compile("com.beust:jcommander:1.71")</code></pre>
2042</div>
2043</div>
2044<div class="ulist">
2045<ul>
2046<li>
2047<p>Gradle</p>
2048</li>
2049</ul>
2050</div>
2051<div class="listingblock">
2052<div class="content">
2053<pre class="prettyprint highlight"><code class="language-groovy" data-lang="groovy">compile "com.beust:jcommander:1.71"</code></pre>
2054</div>
2055</div>
2056<div class="ulist">
2057<ul>
2058<li>
2059<p>Maven:</p>
2060</li>
2061</ul>
2062</div>
2063<div class="listingblock">
2064<div class="content">
2065<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml">&lt;dependency&gt;
2066  &lt;groupId&gt;com.beust&lt;/groupId&gt;
2067  &lt;artifactId&gt;jcommander&lt;/artifactId&gt;
2068  &lt;version&gt;1.71&lt;/version&gt;
2069&lt;/dependency&gt;</code></pre>
2070</div>
2071</div>
2072</div>
2073</div>
2074</div>
2075<div id="footer">
2076<div id="footer-text">
2077Last updated 2017-05-02 10:07:41 PDT
2078</div>
2079</div>
2080<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
2081<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
2082<script>prettyPrint()</script>
2083</body>
2084</html>