blob: 57572718ae7780754ebd20bccc16830bf3dcf638 [file] [log] [blame]
Junio C Hamano944ce252018-05-30 22:25:261<?xml version="1.0" encoding="UTF-8"?>
Junio C Hamano3dac5042007-12-15 08:40:542<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5<head>
Junio C Hamano9d971152012-12-19 00:43:116<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
Junio C Hamanoeaa95f72020-04-14 17:39:357<meta name="generator" content="AsciiDoc 9.0.0rc1" />
Junio C Hamano97bcb482010-11-25 03:16:078<title>parse-options API</title>
Junio C Hamano3dac5042007-12-15 08:40:549<style type="text/css">
Junio C Hamano9d971152012-12-19 00:43:1110/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
11
12/* Default font. */
13body {
14 font-family: Georgia,serif;
15}
16
17/* Title font. */
18h1, h2, h3, h4, h5, h6,
19div.title, caption.title,
20thead, p.table.header,
21#toctitle,
22#author, #revnumber, #revdate, #revremark,
23#footer {
24 font-family: Arial,Helvetica,sans-serif;
Junio C Hamano3dac5042007-12-15 08:40:5425}
26
27body {
28 margin: 1em 5% 1em 5%;
29}
30
Junio C Hamano4604fe52008-09-19 06:37:1031a {
32 color: blue;
33 text-decoration: underline;
34}
35a:visited {
36 color: fuchsia;
37}
Junio C Hamano3dac5042007-12-15 08:40:5438
39em {
40 font-style: italic;
Junio C Hamano97bcb482010-11-25 03:16:0741 color: navy;
Junio C Hamano3dac5042007-12-15 08:40:5442}
43
44strong {
45 font-weight: bold;
Junio C Hamano97bcb482010-11-25 03:16:0746 color: #083194;
Junio C Hamano3dac5042007-12-15 08:40:5447}
48
Junio C Hamano3dac5042007-12-15 08:40:5449h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
Junio C Hamano3dac5042007-12-15 08:40:5451 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
54}
55
Junio C Hamano4604fe52008-09-19 06:37:1056h1, h2, h3 {
Junio C Hamano3dac5042007-12-15 08:40:5457 border-bottom: 2px solid silver;
58}
59h2 {
Junio C Hamano3dac5042007-12-15 08:40:5460 padding-top: 0.5em;
61}
Junio C Hamano4604fe52008-09-19 06:37:1062h3 {
63 float: left;
64}
65h3 + * {
66 clear: left;
67}
Junio C Hamano9d971152012-12-19 00:43:1168h5 {
69 font-size: 1.0em;
70}
Junio C Hamano3dac5042007-12-15 08:40:5471
72div.sectionbody {
Junio C Hamano3dac5042007-12-15 08:40:5473 margin-left: 0;
74}
75
76hr {
77 border: 1px solid silver;
78}
79
80p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
83}
84
Junio C Hamano97bcb482010-11-25 03:16:0785ul, ol, li > p {
86 margin-top: 0;
87}
Junio C Hamano9d971152012-12-19 00:43:1188ul > li { color: #aaa; }
89ul > li > * { color: black; }
Junio C Hamano97bcb482010-11-25 03:16:0790
Junio C Hamanoc14e6ad2014-10-31 20:25:5391.monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
Junio C Hamano3dac5042007-12-15 08:40:5495 padding: 0;
96 margin: 0;
97}
Junio C Hamanoc14e6ad2014-10-31 20:25:5398pre {
99 white-space: pre-wrap;
100}
Junio C Hamano3dac5042007-12-15 08:40:54101
Junio C Hamano9d971152012-12-19 00:43:11102#author {
Junio C Hamano3dac5042007-12-15 08:40:54103 color: #527bbd;
Junio C Hamano3dac5042007-12-15 08:40:54104 font-weight: bold;
Junio C Hamano4604fe52008-09-19 06:37:10105 font-size: 1.1em;
Junio C Hamano3dac5042007-12-15 08:40:54106}
Junio C Hamano9d971152012-12-19 00:43:11107#email {
Junio C Hamano3dac5042007-12-15 08:40:54108}
Junio C Hamano9d971152012-12-19 00:43:11109#revnumber, #revdate, #revremark {
Junio C Hamano3dac5042007-12-15 08:40:54110}
111
Junio C Hamano9d971152012-12-19 00:43:11112#footer {
Junio C Hamano3dac5042007-12-15 08:40:54113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
117}
Junio C Hamano9d971152012-12-19 00:43:11118#footer-text {
Junio C Hamano3dac5042007-12-15 08:40:54119 float: left;
120 padding-bottom: 0.5em;
121}
Junio C Hamano9d971152012-12-19 00:43:11122#footer-badges {
Junio C Hamano3dac5042007-12-15 08:40:54123 float: right;
124 padding-bottom: 0.5em;
125}
126
Junio C Hamano9d971152012-12-19 00:43:11127#preamble {
Junio C Hamano97bcb482010-11-25 03:16:07128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
130}
Junio C Hamano9d971152012-12-19 00:43:11131div.imageblock, div.exampleblock, div.verseblock,
Junio C Hamano3dac5042007-12-15 08:40:54132div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22134 margin-top: 1.0em;
Junio C Hamano3dac5042007-12-15 08:40:54135 margin-bottom: 1.5em;
136}
137div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
Junio C Hamano3dac5042007-12-15 08:40:54142}
143
144div.content { /* Block element content. */
145 padding: 0;
146}
147
148/* Block element titles. */
149div.title, caption.title {
Junio C Hamano97bcb482010-11-25 03:16:07150 color: #527bbd;
Junio C Hamano3dac5042007-12-15 08:40:54151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
155}
156div.title + * {
157 margin-top: 0;
158}
159
160td div.title:first-child {
161 margin-top: 0.0em;
162}
163div.content div.title:first-child {
164 margin-top: 0.0em;
165}
166div.content + div.title {
167 margin-top: 0.0em;
168}
169
170div.sidebarblock > div.content {
171 background: #ffffee;
Junio C Hamano9d971152012-12-19 00:43:11172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
Junio C Hamano3dac5042007-12-15 08:40:54174 padding: 0.5em;
175}
176
177div.listingblock > div.content {
Junio C Hamano9d971152012-12-19 00:43:11178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
Junio C Hamano3dac5042007-12-15 08:40:54181 padding: 0.5em;
182}
183
Junio C Hamano7bd050f2011-09-22 06:32:22184div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
Junio C Hamano97bcb482010-11-25 03:16:07187 margin-right: 10%;
Junio C Hamano9d971152012-12-19 00:43:11188 border-left: 5px solid #f0f0f0;
189 color: #888;
Junio C Hamano3dac5042007-12-15 08:40:54190}
Junio C Hamano7bd050f2011-09-22 06:32:22191
Junio C Hamano97bcb482010-11-25 03:16:07192div.quoteblock > div.attribution {
193 padding-top: 0.5em;
Junio C Hamano3dac5042007-12-15 08:40:54194 text-align: right;
195}
Junio C Hamano97bcb482010-11-25 03:16:07196
Junio C Hamano9d971152012-12-19 00:43:11197div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
Junio C Hamano97bcb482010-11-25 03:16:07200}
201div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
204}
205/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamano4604fe52008-09-19 06:37:10206div.verseblock + div.attribution {
207 text-align: left;
208}
Junio C Hamano3dac5042007-12-15 08:40:54209
210div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
217}
218div.admonitionblock td.content {
219 padding-left: 0.5em;
Junio C Hamano7bd050f2011-09-22 06:32:22220 border-left: 3px solid #dddddd;
Junio C Hamano3dac5042007-12-15 08:40:54221}
222
223div.exampleblock > div.content {
Junio C Hamano7bd050f2011-09-22 06:32:22224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
Junio C Hamano3dac5042007-12-15 08:40:54226}
227
Junio C Hamano3dac5042007-12-15 08:40:54228div.imageblock div.content { padding-left: 0; }
Junio C Hamanoc14e6ad2014-10-31 20:25:53229span.image img { border-style: none; vertical-align: text-bottom; }
Junio C Hamano97bcb482010-11-25 03:16:07230a.image:visited { color: white; }
Junio C Hamano3dac5042007-12-15 08:40:54231
232dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
235}
236dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
Junio C Hamano97bcb482010-11-25 03:16:07239 font-style: normal;
240 color: navy;
Junio C Hamano3dac5042007-12-15 08:40:54241}
242dd > *:first-child {
Junio C Hamano97bcb482010-11-25 03:16:07243 margin-top: 0.1em;
Junio C Hamano3dac5042007-12-15 08:40:54244}
245
246ul, ol {
247 list-style-position: outside;
248}
Junio C Hamano97bcb482010-11-25 03:16:07249ol.arabic {
250 list-style-type: decimal;
251}
252ol.loweralpha {
Junio C Hamano3dac5042007-12-15 08:40:54253 list-style-type: lower-alpha;
254}
Junio C Hamano97bcb482010-11-25 03:16:07255ol.upperalpha {
256 list-style-type: upper-alpha;
257}
258ol.lowerroman {
259 list-style-type: lower-roman;
260}
261ol.upperroman {
262 list-style-type: upper-roman;
263}
264
265div.compact ul, div.compact ol,
266div.compact p, div.compact p,
267div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
270}
Junio C Hamano3dac5042007-12-15 08:40:54271
Junio C Hamano3dac5042007-12-15 08:40:54272tfoot {
273 font-weight: bold;
274}
Junio C Hamano97bcb482010-11-25 03:16:07275td > div.verse {
276 white-space: pre;
277}
Junio C Hamano97bcb482010-11-25 03:16:07278
279div.hdlist {
Junio C Hamano3dac5042007-12-15 08:40:54280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
282}
Junio C Hamano97bcb482010-11-25 03:16:07283div.hdlist tr {
284 padding-bottom: 15px;
Junio C Hamano4604fe52008-09-19 06:37:10285}
Junio C Hamano97bcb482010-11-25 03:16:07286dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
288}
289td.hdlist1 {
Junio C Hamano3dac5042007-12-15 08:40:54290 vertical-align: top;
Junio C Hamano97bcb482010-11-25 03:16:07291 font-style: normal;
Junio C Hamano3dac5042007-12-15 08:40:54292 padding-right: 0.8em;
Junio C Hamano97bcb482010-11-25 03:16:07293 color: navy;
Junio C Hamano3dac5042007-12-15 08:40:54294}
Junio C Hamano97bcb482010-11-25 03:16:07295td.hdlist2 {
Junio C Hamano3dac5042007-12-15 08:40:54296 vertical-align: top;
297}
Junio C Hamano97bcb482010-11-25 03:16:07298div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
301}
302
303.comment {
304 background: yellow;
305}
Junio C Hamano3dac5042007-12-15 08:40:54306
Junio C Hamano7bd050f2011-09-22 06:32:22307.footnote, .footnoteref {
308 font-size: 0.8em;
309}
310
311span.footnote, span.footnoteref {
312 vertical-align: super;
313}
314
315#footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
318}
319
320#footnotes div.footnote {
321 margin: 0 0 5px 0;
322}
323
324#footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
332}
333
Junio C Hamano9d971152012-12-19 00:43:11334div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
338}
339div.colist td img {
340 margin-top: 0.3em;
Junio C Hamano3dac5042007-12-15 08:40:54341}
Junio C Hamano4604fe52008-09-19 06:37:10342
Junio C Hamano9d971152012-12-19 00:43:11343@media print {
344 #footer-badges { display: none; }
345}
346
347#toc {
Junio C Hamano7bd050f2011-09-22 06:32:22348 margin-bottom: 2.5em;
349}
350
Junio C Hamano9d971152012-12-19 00:43:11351#toctitle {
Junio C Hamano4604fe52008-09-19 06:37:10352 color: #527bbd;
Junio C Hamano4604fe52008-09-19 06:37:10353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
357}
358
Junio C Hamanoc14e6ad2014-10-31 20:25:53359div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamano4604fe52008-09-19 06:37:10360 margin-top: 0;
361 margin-bottom: 0;
362}
363div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
366}
367div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
370}
371div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
374}
Junio C Hamano3dac5042007-12-15 08:40:54375
Junio C Hamano9d971152012-12-19 00:43:11376span.aqua { color: aqua; }
377span.black { color: black; }
378span.blue { color: blue; }
379span.fuchsia { color: fuchsia; }
380span.gray { color: gray; }
381span.green { color: green; }
382span.lime { color: lime; }
383span.maroon { color: maroon; }
384span.navy { color: navy; }
385span.olive { color: olive; }
386span.purple { color: purple; }
387span.red { color: red; }
388span.silver { color: silver; }
389span.teal { color: teal; }
390span.white { color: white; }
391span.yellow { color: yellow; }
392
393span.aqua-background { background: aqua; }
394span.black-background { background: black; }
395span.blue-background { background: blue; }
396span.fuchsia-background { background: fuchsia; }
397span.gray-background { background: gray; }
398span.green-background { background: green; }
399span.lime-background { background: lime; }
400span.maroon-background { background: maroon; }
401span.navy-background { background: navy; }
402span.olive-background { background: olive; }
403span.purple-background { background: purple; }
404span.red-background { background: red; }
405span.silver-background { background: silver; }
406span.teal-background { background: teal; }
407span.white-background { background: white; }
408span.yellow-background { background: yellow; }
409
410span.big { font-size: 2em; }
411span.small { font-size: 0.6em; }
412
413span.underline { text-decoration: underline; }
414span.overline { text-decoration: overline; }
415span.line-through { text-decoration: line-through; }
416
Junio C Hamanoc14e6ad2014-10-31 20:25:53417div.unbreakable { page-break-inside: avoid; }
418
Junio C Hamano9d971152012-12-19 00:43:11419
420/*
421 * xhtml11 specific
422 *
423 * */
424
425div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
Junio C Hamano3dac5042007-12-15 08:40:54428}
Junio C Hamano9d971152012-12-19 00:43:11429div.tableblock > table {
430 border: 3px solid #527bbd;
431}
432thead, p.table.header {
Junio C Hamano3dac5042007-12-15 08:40:54433 font-weight: bold;
Junio C Hamano9d971152012-12-19 00:43:11434 color: #527bbd;
435}
436p.table {
437 margin-top: 0;
438}
Junio C Hamano725b0da2020-01-22 22:02:40439/* Because the table frame attribute is overridden by CSS in most browsers. */
Junio C Hamano9d971152012-12-19 00:43:11440div.tableblock > table[frame="void"] {
441 border-style: none;
442}
443div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
446}
447div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
Junio C Hamano3dac5042007-12-15 08:40:54450}
451
Junio C Hamano9d971152012-12-19 00:43:11452
453/*
454 * html5 specific
455 *
456 * */
457
458table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
461}
462thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
465}
466p.tableblock {
467 margin-top: 0;
468}
469table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
475}
476th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
Junio C Hamano3dac5042007-12-15 08:40:54481}
482
Junio C Hamano9d971152012-12-19 00:43:11483table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
486}
487table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
490}
491table.tableblock.frame-none {
492 border-style: hidden;
493}
494
495th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
497}
498th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
500}
501th.tableblock.halign-right, td.tableblock.halign-right {
Junio C Hamano97bcb482010-11-25 03:16:07502 text-align: right;
503}
504
Junio C Hamano9d971152012-12-19 00:43:11505th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
Junio C Hamano97bcb482010-11-25 03:16:07507}
Junio C Hamano9d971152012-12-19 00:43:11508th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
510}
511th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
Junio C Hamano3dac5042007-12-15 08:40:54513}
514
Junio C Hamano9d971152012-12-19 00:43:11515
516/*
517 * manpage specific
518 *
519 * */
520
521body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
526}
527body.manpage h2 {
528 border-style: none;
529}
530body.manpage div.sectionbody {
531 margin-left: 3em;
Junio C Hamano3dac5042007-12-15 08:40:54532}
Junio C Hamano4604fe52008-09-19 06:37:10533
Junio C Hamano9d971152012-12-19 00:43:11534@media print {
535 body.manpage div#toc { display: none; }
536}
Junio C Hamanoc14e6ad2014-10-31 20:25:53537
538
Junio C Hamano3dac5042007-12-15 08:40:54539</style>
Junio C Hamano7bd050f2011-09-22 06:32:22540<script type="text/javascript">
541/*<![CDATA[*/
Junio C Hamano7bd050f2011-09-22 06:32:22542var asciidoc = { // Namespace.
543
544/////////////////////////////////////////////////////////////////////
545// Table Of Contents generator
546/////////////////////////////////////////////////////////////////////
547
548/* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
550 *
551 * Table Of Content generator
552 * Version: 0.4
553 *
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
556 */
557
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
560
561// toclevels = 1..4.
562toc: function (toclevels) {
563
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
571 }
572 return text;
573 }
574
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
579 }
580
581 function tocEntries(el, toclevels) {
582 var result = new Array;
Junio C Hamanoc14e6ad2014-10-31 20:25:53583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
Junio C Hamano7bd050f2011-09-22 06:32:22584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
593 }
594 iterate(i);
595 }
596 }
597 }
598 iterate(el);
599 return result;
600 }
601
602 var toc = document.getElementById("toc");
Junio C Hamano9d971152012-12-19 00:43:11603 if (!toc) {
604 return;
605 }
606
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
Junio C Hamanoc14e6ad2014-10-31 20:25:53612 if (entry.nodeName.toLowerCase() == 'div'
Junio C Hamano9d971152012-12-19 00:43:11613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
616 }
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
619 }
620
621 // Rebuild TOC entries.
Junio C Hamano7bd050f2011-09-22 06:32:22622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
634 }
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
637},
638
639
640/////////////////////////////////////////////////////////////////////
641// Footnotes generator
642/////////////////////////////////////////////////////////////////////
643
644/* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
646 */
647
648footnotes: function () {
Junio C Hamano9d971152012-12-19 00:43:11649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
Junio C Hamano7bd050f2011-09-22 06:32:22651 var noteholder = document.getElementById("footnotes");
Junio C Hamano9d971152012-12-19 00:43:11652 if (!noteholder) {
653 return;
654 }
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
Junio C Hamanoc14e6ad2014-10-31 20:25:53658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
Junio C Hamano9d971152012-12-19 00:43:11659 entriesToRemove.push(entry);
660 }
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
663 }
664
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
Junio C Hamano7bd050f2011-09-22 06:32:22667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
Junio C Hamano9d971152012-12-19 00:43:11673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
682 }
Junio C Hamano7bd050f2011-09-22 06:32:22683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
Junio C Hamano7bd050f2011-09-22 06:32:22687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
689 }
690 }
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
703 }
704 }
705 }
Junio C Hamano9d971152012-12-19 00:43:11706},
707
708install: function(toclevels) {
709 var timerId;
710
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
715 }
716 }
717
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
721 }
722
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
Junio C Hamano7bd050f2011-09-22 06:32:22728}
729
730}
Junio C Hamano9d971152012-12-19 00:43:11731asciidoc.install();
Junio C Hamano7bd050f2011-09-22 06:32:22732/*]]>*/
733</script>
Junio C Hamano3dac5042007-12-15 08:40:54734</head>
Junio C Hamano9d971152012-12-19 00:43:11735<body class="article">
Junio C Hamano3dac5042007-12-15 08:40:54736<div id="header">
737<h1>parse-options API</h1>
738</div>
Junio C Hamano7bd050f2011-09-22 06:32:22739<div id="content">
Junio C Hamano3dac5042007-12-15 08:40:54740<div id="preamble">
741<div class="sectionbody">
Junio C Hamano076ffcc2013-02-06 05:13:21742<div class="paragraph"><p>The parse-options API is used to parse and massage options in Git
Junio C Hamano4604fe52008-09-19 06:37:10743and to provide a usage help with consistent look.</p></div>
Junio C Hamano3dac5042007-12-15 08:40:54744</div>
745</div>
Junio C Hamano9d971152012-12-19 00:43:11746<div class="sect1">
Junio C Hamano4604fe52008-09-19 06:37:10747<h2 id="_basics">Basics</h2>
Junio C Hamano4224f992008-06-23 07:14:08748<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:53749<div class="paragraph"><p>The argument vector <code>argv[]</code> may usually contain mandatory or optional
Junio C Hamano4224f992008-06-23 07:14:08750<em>non-option arguments</em>, e.g. a filename or a branch, and <em>options</em>.
751Options are optional arguments that start with a dash and
Junio C Hamano4604fe52008-09-19 06:37:10752that allow to change the behavior of a command.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07753<div class="ulist"><ul>
Junio C Hamano4224f992008-06-23 07:14:08754<li>
755<p>
756There are basically three types of options:
757 <em>boolean</em> options,
758 options with (mandatory) <em>arguments</em> and
759 options with <em>optional arguments</em>
760 (i.e. a boolean option that can be adjusted).
761</p>
762</li>
763<li>
764<p>
765There are basically two forms of options:
Junio C Hamanoc14e6ad2014-10-31 20:25:53766 <em>Short options</em> consist of one dash (<code>-</code>) and one alphanumeric
Junio C Hamano4224f992008-06-23 07:14:08767 character.
Junio C Hamanoc14e6ad2014-10-31 20:25:53768 <em>Long options</em> begin with two dashes (<code>--</code>) and some
Junio C Hamano4224f992008-06-23 07:14:08769 alphanumeric characters.
770</p>
771</li>
772<li>
773<p>
774Options are case-sensitive.
775 Please define <em>lower-case long options</em> only.
776</p>
777</li>
Junio C Hamano4604fe52008-09-19 06:37:10778</ul></div>
Junio C Hamano97bcb482010-11-25 03:16:07779<div class="paragraph"><p>The parse-options API allows:</p></div>
780<div class="ulist"><ul>
Junio C Hamano4224f992008-06-23 07:14:08781<li>
782<p>
Junio C Hamanof079f702013-12-06 23:43:18783<em>stuck</em> and <em>separate form</em> of options with arguments.
Junio C Hamanoc14e6ad2014-10-31 20:25:53784 <code>-oArg</code> is stuck, <code>-o Arg</code> is separate form.
785 <code>--option=Arg</code> is stuck, <code>--option Arg</code> is separate form.
Junio C Hamano4224f992008-06-23 07:14:08786</p>
787</li>
788<li>
789<p>
790Long options may be <em>abbreviated</em>, as long as the abbreviation
791 is unambiguous.
792</p>
793</li>
794<li>
795<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53796Short options may be bundled, e.g. <code>-a -b</code> can be specified as <code>-ab</code>.
Junio C Hamano4224f992008-06-23 07:14:08797</p>
798</li>
799<li>
800<p>
801Boolean long options can be <em>negated</em> (or <em>unset</em>) by prepending
Junio C Hamanoc14e6ad2014-10-31 20:25:53802 <code>no-</code>, e.g. <code>--no-abbrev</code> instead of <code>--abbrev</code>. Conversely,
803 options that begin with <code>no-</code> can be <em>negated</em> by removing it.
Junio C Hamanoc7102962013-05-29 23:57:17804 Other long options can be unset (e.g., set string to NULL, set
Junio C Hamanoc14e6ad2014-10-31 20:25:53805 integer to 0) by prepending <code>no-</code>.
Junio C Hamano4224f992008-06-23 07:14:08806</p>
807</li>
808<li>
809<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53810Options and non-option arguments can clearly be separated using the <code>--</code>
811 option, e.g. <code>-a -b --option -- --this-is-a-file</code> indicates that
812 <code>--this-is-a-file</code> must not be processed as an option.
Junio C Hamano4224f992008-06-23 07:14:08813</p>
814</li>
Junio C Hamano4604fe52008-09-19 06:37:10815</ul></div>
Junio C Hamano4224f992008-06-23 07:14:08816</div>
Junio C Hamano9d971152012-12-19 00:43:11817</div>
818<div class="sect1">
Junio C Hamano4604fe52008-09-19 06:37:10819<h2 id="_steps_to_parse_options">Steps to parse options</h2>
Junio C Hamano4224f992008-06-23 07:14:08820<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07821<div class="olist arabic"><ol class="arabic">
Junio C Hamano4224f992008-06-23 07:14:08822<li>
823<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53824<code>#include "parse-options.h"</code>
Junio C Hamano4224f992008-06-23 07:14:08825</p>
826</li>
827<li>
828<p>
829define a NULL-terminated
Junio C Hamanoc14e6ad2014-10-31 20:25:53830 <code>static const char * const builtin_foo_usage[]</code> array
Junio C Hamano4224f992008-06-23 07:14:08831 containing alternative usage strings
832</p>
833</li>
834<li>
835<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53836define <code>builtin_foo_options</code> array as described below
Junio C Hamano4224f992008-06-23 07:14:08837 in section <em>Data Structure</em>.
838</p>
839</li>
840<li>
841<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53842in <code>cmd_foo(int argc, const char **argv, const char *prefix)</code>
Junio C Hamano4224f992008-06-23 07:14:08843 call
844</p>
845<div class="literalblock">
846<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53847<pre><code>argc = parse_options(argc, argv, prefix, builtin_foo_options, builtin_foo_usage, flags);</code></pre>
Junio C Hamano4224f992008-06-23 07:14:08848</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53849<div class="paragraph"><p><code>parse_options()</code> will filter out the processed options of <code>argv[]</code> and leave the
850non-option arguments in <code>argv[]</code>.
851<code>argc</code> is updated appropriately because of the assignment.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07852<div class="paragraph"><p>You can also pass NULL instead of a usage array as the fifth parameter of
Junio C Hamano18f51402009-03-10 16:39:13853parse_options(), to avoid displaying a help screen with usage info and
854option list. This should only be done if necessary, e.g. to implement
855a limited parser for only a subset of the options that needs to be run
856before the full parser, which in turn shows the full help message.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07857<div class="paragraph"><p>Flags are the bitwise-or of:</p></div>
858<div class="dlist"><dl>
859<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53860<code>PARSE_OPT_KEEP_DASHDASH</code>
Junio C Hamano4224f992008-06-23 07:14:08861</dt>
862<dd>
863<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53864 Keep the <code>--</code> that usually separates options from
Junio C Hamano4224f992008-06-23 07:14:08865 non-option arguments.
866</p>
867</dd>
Junio C Hamano97bcb482010-11-25 03:16:07868<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53869<code>PARSE_OPT_STOP_AT_NON_OPTION</code>
Junio C Hamano4224f992008-06-23 07:14:08870</dt>
871<dd>
872<p>
873 Usually the whole argument vector is massaged and reordered.
874 Using this flag, processing is stopped at the first non-option
875 argument.
876</p>
877</dd>
Junio C Hamano97bcb482010-11-25 03:16:07878<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53879<code>PARSE_OPT_KEEP_ARGV0</code>
Junio C Hamano18f51402009-03-10 16:39:13880</dt>
881<dd>
882<p>
Junio C Hamano97bcb482010-11-25 03:16:07883 Keep the first argument, which contains the program name. It&#8217;s
Junio C Hamano18f51402009-03-10 16:39:13884 removed from argv[] by default.
885</p>
886</dd>
Junio C Hamano97bcb482010-11-25 03:16:07887<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53888<code>PARSE_OPT_KEEP_UNKNOWN</code>
Junio C Hamano18f51402009-03-10 16:39:13889</dt>
890<dd>
891<p>
Junio C Hamano97bcb482010-11-25 03:16:07892 Keep unknown arguments instead of erroring out. This doesn&#8217;t
Junio C Hamano18f51402009-03-10 16:39:13893 work for all combinations of arguments as users might expect
Junio C Hamanoc14e6ad2014-10-31 20:25:53894 it to do. E.g. if the first argument in <code>--unknown --known</code>
Junio C Hamano97bcb482010-11-25 03:16:07895 takes a value (which we can&#8217;t know), the second one is
Junio C Hamano18f51402009-03-10 16:39:13896 mistakenly interpreted as a known option. Similarly, if
Junio C Hamanoc14e6ad2014-10-31 20:25:53897 <code>PARSE_OPT_STOP_AT_NON_OPTION</code> is set, the second argument in
898 <code>--unknown value</code> will be mistakenly interpreted as a
Junio C Hamano18f51402009-03-10 16:39:13899 non-option, not as a value belonging to the unknown option,
Junio C Hamano97bcb482010-11-25 03:16:07900 the parser early. That&#8217;s why parse_options() errors out if
Junio C Hamano18f51402009-03-10 16:39:13901 both options are set.
902</p>
903</dd>
Junio C Hamano97bcb482010-11-25 03:16:07904<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53905<code>PARSE_OPT_NO_INTERNAL_HELP</code>
Junio C Hamano18f51402009-03-10 16:39:13906</dt>
907<dd>
908<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53909 By default, parse_options() handles <code>-h</code>, <code>--help</code> and
910 <code>--help-all</code> internally, by showing a help screen. This option
Junio C Hamano18f51402009-03-10 16:39:13911 turns it off and allows one to add custom handlers for these
912 options, or to just leave them unknown.
913</p>
914</dd>
Junio C Hamano4604fe52008-09-19 06:37:10915</dl></div>
Junio C Hamano4224f992008-06-23 07:14:08916</li>
Junio C Hamano4604fe52008-09-19 06:37:10917</ol></div>
Junio C Hamano4224f992008-06-23 07:14:08918</div>
Junio C Hamano9d971152012-12-19 00:43:11919</div>
920<div class="sect1">
Junio C Hamano4604fe52008-09-19 06:37:10921<h2 id="_data_structure">Data Structure</h2>
Junio C Hamano4224f992008-06-23 07:14:08922<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:53923<div class="paragraph"><p>The main data structure is an array of the <code>option</code> struct,
924say <code>static struct option builtin_add_options[]</code>.
Junio C Hamano4604fe52008-09-19 06:37:10925There are some macros to easily define options:</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07926<div class="dlist"><dl>
927<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53928<code>OPT__ABBREV(&amp;int_var)</code>
Junio C Hamano4224f992008-06-23 07:14:08929</dt>
930<dd>
931<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53932 Add <code>--abbrev[=&lt;n&gt;]</code>.
Junio C Hamano4224f992008-06-23 07:14:08933</p>
934</dd>
Junio C Hamano97bcb482010-11-25 03:16:07935<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53936<code>OPT__COLOR(&amp;int_var, description)</code>
Junio C Hamano4aa0bcc2010-03-03 05:13:12937</dt>
938<dd>
939<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53940 Add <code>--color[=&lt;when&gt;]</code> and <code>--no-color</code>.
Junio C Hamano4aa0bcc2010-03-03 05:13:12941</p>
942</dd>
Junio C Hamano97bcb482010-11-25 03:16:07943<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53944<code>OPT__DRY_RUN(&amp;int_var, description)</code>
Junio C Hamano4224f992008-06-23 07:14:08945</dt>
946<dd>
947<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53948 Add <code>-n, --dry-run</code>.
Junio C Hamano4224f992008-06-23 07:14:08949</p>
950</dd>
Junio C Hamano97bcb482010-11-25 03:16:07951<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53952<code>OPT__FORCE(&amp;int_var, description)</code>
Junio C Hamano97bcb482010-11-25 03:16:07953</dt>
954<dd>
955<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53956 Add <code>-f, --force</code>.
Junio C Hamano97bcb482010-11-25 03:16:07957</p>
958</dd>
959<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53960<code>OPT__QUIET(&amp;int_var, description)</code>
Junio C Hamano4224f992008-06-23 07:14:08961</dt>
962<dd>
963<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53964 Add <code>-q, --quiet</code>.
Junio C Hamano4224f992008-06-23 07:14:08965</p>
966</dd>
Junio C Hamano97bcb482010-11-25 03:16:07967<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53968<code>OPT__VERBOSE(&amp;int_var, description)</code>
Junio C Hamano4224f992008-06-23 07:14:08969</dt>
970<dd>
971<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53972 Add <code>-v, --verbose</code>.
Junio C Hamano4224f992008-06-23 07:14:08973</p>
974</dd>
Junio C Hamano97bcb482010-11-25 03:16:07975<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53976<code>OPT_GROUP(description)</code>
Junio C Hamano4224f992008-06-23 07:14:08977</dt>
978<dd>
979<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53980 Start an option group. <code>description</code> is a short string that
Junio C Hamano4224f992008-06-23 07:14:08981 describes the group or an empty string.
982 Start the description with an upper-case letter.
983</p>
984</dd>
Junio C Hamano97bcb482010-11-25 03:16:07985<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53986<code>OPT_BOOL(short, long, &amp;int_var, description)</code>
Junio C Hamano4224f992008-06-23 07:14:08987</dt>
988<dd>
989<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53990 Introduce a boolean option. <code>int_var</code> is set to one with
991 <code>--option</code> and set to zero with <code>--no-option</code>.
Junio C Hamano4c6612f2011-10-12 23:54:21992</p>
993</dd>
994<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:53995<code>OPT_COUNTUP(short, long, &amp;int_var, description)</code>
Junio C Hamano4c6612f2011-10-12 23:54:21996</dt>
997<dd>
998<p>
999 Introduce a count-up option.
Junio C Hamanof2a3a752016-05-23 22:54:391000 Each use of <code>--option</code> increments <code>int_var</code>, starting from zero
1001 (even if initially negative), and <code>--no-option</code> resets it to
1002 zero. To determine if <code>--option</code> or <code>--no-option</code> was encountered at
1003 all, initialize <code>int_var</code> to a negative value, and if it is still
1004 negative after parse_options(), then neither <code>--option</code> nor
1005 <code>--no-option</code> was seen.
Junio C Hamano4224f992008-06-23 07:14:081006</p>
1007</dd>
Junio C Hamano97bcb482010-11-25 03:16:071008<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531009<code>OPT_BIT(short, long, &amp;int_var, description, mask)</code>
Junio C Hamano4224f992008-06-23 07:14:081010</dt>
1011<dd>
1012<p>
1013 Introduce a boolean option.
Junio C Hamanoc14e6ad2014-10-31 20:25:531014 If used, <code>int_var</code> is bitwise-ored with <code>mask</code>.
Junio C Hamano4224f992008-06-23 07:14:081015</p>
1016</dd>
Junio C Hamano97bcb482010-11-25 03:16:071017<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531018<code>OPT_NEGBIT(short, long, &amp;int_var, description, mask)</code>
Junio C Hamano7ae18252009-05-23 09:53:321019</dt>
1020<dd>
1021<p>
1022 Introduce a boolean option.
Junio C Hamanoc14e6ad2014-10-31 20:25:531023 If used, <code>int_var</code> is bitwise-anded with the inverted <code>mask</code>.
Junio C Hamano7ae18252009-05-23 09:53:321024</p>
1025</dd>
Junio C Hamano97bcb482010-11-25 03:16:071026<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531027<code>OPT_SET_INT(short, long, &amp;int_var, description, integer)</code>
Junio C Hamano4224f992008-06-23 07:14:081028</dt>
1029<dd>
1030<p>
Junio C Hamano4c6612f2011-10-12 23:54:211031 Introduce an integer option.
Junio C Hamanoc14e6ad2014-10-31 20:25:531032 <code>int_var</code> is set to <code>integer</code> with <code>--option</code>, and
1033 reset to zero with <code>--no-option</code>.
Junio C Hamano4224f992008-06-23 07:14:081034</p>
1035</dd>
Junio C Hamano97bcb482010-11-25 03:16:071036<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531037<code>OPT_STRING(short, long, &amp;str_var, arg_str, description)</code>
Junio C Hamano4224f992008-06-23 07:14:081038</dt>
1039<dd>
1040<p>
1041 Introduce an option with string argument.
Junio C Hamanoc14e6ad2014-10-31 20:25:531042 The string argument is put into <code>str_var</code>.
Junio C Hamano4224f992008-06-23 07:14:081043</p>
1044</dd>
Junio C Hamano97bcb482010-11-25 03:16:071045<dt class="hdlist1">
Junio C Hamanocbe0eb22017-02-27 23:37:491046<code>OPT_STRING_LIST(short, long, &amp;struct string_list, arg_str, description)</code>
1047</dt>
1048<dd>
1049<p>
1050 Introduce an option with string argument.
1051 The string argument is stored as an element in <code>string_list</code>.
1052 Use of <code>--no-option</code> will clear the list of preceding values.
1053</p>
1054</dd>
1055<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531056<code>OPT_INTEGER(short, long, &amp;int_var, description)</code>
Junio C Hamano4224f992008-06-23 07:14:081057</dt>
1058<dd>
1059<p>
1060 Introduce an option with integer argument.
Junio C Hamanoc14e6ad2014-10-31 20:25:531061 The integer is put into <code>int_var</code>.
Junio C Hamano4224f992008-06-23 07:14:081062</p>
1063</dd>
Junio C Hamano97bcb482010-11-25 03:16:071064<dt class="hdlist1">
Junio C Hamanod7ed4042015-08-03 19:43:001065<code>OPT_MAGNITUDE(short, long, &amp;unsigned_long_var, description)</code>
1066</dt>
1067<dd>
1068<p>
1069 Introduce an option with a size argument. The argument must be a
1070 non-negative integer and may include a suffix of <em>k</em>, <em>m</em> or <em>g</em> to
1071 scale the provided value by 1024, 1024<sup>2 or 1024</sup>3 respectively.
1072 The scaled value is put into <code>unsigned_long_var</code>.
1073</p>
1074</dd>
1075<dt class="hdlist1">
Junio C Hamanod5176902017-05-16 04:30:561076<code>OPT_EXPIRY_DATE(short, long, &amp;timestamp_t_var, description)</code>
Junio C Hamanoc7102962013-05-29 23:57:171077</dt>
1078<dd>
1079<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531080 Introduce an option with expiry date argument, see <code>parse_expiry_date()</code>.
Junio C Hamanod5176902017-05-16 04:30:561081 The timestamp is put into <code>timestamp_t_var</code>.
Junio C Hamanoc7102962013-05-29 23:57:171082</p>
1083</dd>
1084<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531085<code>OPT_CALLBACK(short, long, &amp;var, arg_str, description, func_ptr)</code>
Junio C Hamano4224f992008-06-23 07:14:081086</dt>
1087<dd>
1088<p>
1089 Introduce an option with argument.
Junio C Hamanoc14e6ad2014-10-31 20:25:531090 The argument will be fed into the function given by <code>func_ptr</code>
1091 and the result will be put into <code>var</code>.
Junio C Hamano4224f992008-06-23 07:14:081092 See <em>Option Callbacks</em> below for a more elaborate description.
1093</p>
1094</dd>
Junio C Hamano97bcb482010-11-25 03:16:071095<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531096<code>OPT_FILENAME(short, long, &amp;var, description)</code>
Junio C Hamano3d141512009-06-01 01:22:401097</dt>
1098<dd>
1099<p>
1100 Introduce an option with a filename argument.
1101 The filename will be prefixed by passing the filename along with
Junio C Hamanoc14e6ad2014-10-31 20:25:531102 the prefix argument of <code>parse_options()</code> to <code>prefix_filename()</code>.
Junio C Hamano3d141512009-06-01 01:22:401103</p>
1104</dd>
Junio C Hamano97bcb482010-11-25 03:16:071105<dt class="hdlist1">
Junio C Hamano2ba14712019-04-25 10:12:271106<code>OPT_ARGUMENT(long, &amp;int_var, description)</code>
Junio C Hamano4224f992008-06-23 07:14:081107</dt>
1108<dd>
1109<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531110 Introduce a long-option argument that will be kept in <code>argv[]</code>.
Junio C Hamano2ba14712019-04-25 10:12:271111 If this option was seen, <code>int_var</code> will be set to one (except
1112 if a <code>NULL</code> pointer was passed).
Junio C Hamano4224f992008-06-23 07:14:081113</p>
1114</dd>
Junio C Hamano97bcb482010-11-25 03:16:071115<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531116<code>OPT_NUMBER_CALLBACK(&amp;var, description, func_ptr)</code>
Junio C Hamano7ae18252009-05-23 09:53:321117</dt>
1118<dd>
1119<p>
1120 Recognize numerical options like -123 and feed the integer as
Junio C Hamanoc14e6ad2014-10-31 20:25:531121 if it was an argument to the function given by <code>func_ptr</code>.
1122 The result will be put into <code>var</code>. There can be only one such
Junio C Hamano7ae18252009-05-23 09:53:321123 option definition. It cannot be negated and it takes no
1124 arguments. Short options that happen to be digits take
1125 precedence over it.
1126</p>
1127</dd>
Junio C Hamano97bcb482010-11-25 03:16:071128<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531129<code>OPT_COLOR_FLAG(short, long, &amp;int_var, description)</code>
Junio C Hamano4aa0bcc2010-03-03 05:13:121130</dt>
1131<dd>
1132<p>
1133 Introduce an option that takes an optional argument that can
1134 have one of three values: "always", "never", or "auto". If the
Junio C Hamanoc14e6ad2014-10-31 20:25:531135 argument is not given, it defaults to "always". The <code>--no-</code> form
1136 works like <code>--long=never</code>; it cannot take an argument. If
1137 "always", set <code>int_var</code> to 1; if "never", set <code>int_var</code> to 0; if
1138 "auto", set <code>int_var</code> to 1 if stdout is a tty or a pager,
Junio C Hamano4aa0bcc2010-03-03 05:13:121139 0 otherwise.
1140</p>
1141</dd>
Junio C Hamano4c6612f2011-10-12 23:54:211142<dt class="hdlist1">
Junio C Hamanoc14e6ad2014-10-31 20:25:531143<code>OPT_NOOP_NOARG(short, long)</code>
Junio C Hamano4c6612f2011-10-12 23:54:211144</dt>
1145<dd>
1146<p>
1147 Introduce an option that has no effect and takes no arguments.
1148 Use it to hide deprecated options that are still to be recognized
1149 and ignored silently.
1150</p>
1151</dd>
Junio C Hamanod7ed4042015-08-03 19:43:001152<dt class="hdlist1">
1153<code>OPT_PASSTHRU(short, long, &amp;char_var, arg_str, description, flags)</code>
1154</dt>
1155<dd>
1156<p>
1157 Introduce an option that will be reconstructed into a char* string,
1158 which must be initialized to NULL. This is useful when you need to
1159 pass the command-line option to another command. Any previous value
1160 will be overwritten, so this should only be used for options where
1161 the last one specified on the command line wins.
1162</p>
1163</dd>
1164<dt class="hdlist1">
Junio C Hamanoc9dd6422020-08-10 23:32:551165<code>OPT_PASSTHRU_ARGV(short, long, &amp;strvec_var, arg_str, description, flags)</code>
Junio C Hamanod7ed4042015-08-03 19:43:001166</dt>
1167<dd>
1168<p>
1169 Introduce an option where all instances of it on the command-line will
Junio C Hamanoc9dd6422020-08-10 23:32:551170 be reconstructed into a strvec. This is useful when you need to
Junio C Hamanod7ed4042015-08-03 19:43:001171 pass the command-line option, which can be specified multiple times,
1172 to another command.
1173</p>
1174</dd>
Junio C Hamano84ea1e42016-04-08 21:53:481175<dt class="hdlist1">
1176<code>OPT_CMDMODE(short, long, &amp;int_var, description, enum_val)</code>
1177</dt>
1178<dd>
1179<p>
1180 Define an "operation mode" option, only one of which in the same
1181 group of "operating mode" options that share the same <code>int_var</code>
1182 can be given by the user. <code>enum_val</code> is set to <code>int_var</code> when the
1183 option is used, but an error is reported if other "operating mode"
1184 option has already set its value to the same <code>int_var</code>.
1185</p>
1186</dd>
Junio C Hamano4604fe52008-09-19 06:37:101187</dl></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531188<div class="paragraph"><p>The last element of the array must be <code>OPT_END()</code>.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071189<div class="paragraph"><p>If not stated otherwise, interpret the arguments as follows:</p></div>
1190<div class="ulist"><ul>
Junio C Hamano4224f992008-06-23 07:14:081191<li>
1192<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531193<code>short</code> is a character for the short option
1194 (e.g. <code>'e'</code> for <code>-e</code>, use <code>0</code> to omit),
Junio C Hamano4224f992008-06-23 07:14:081195</p>
1196</li>
1197<li>
1198<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531199<code>long</code> is a string for the long option
1200 (e.g. <code>"example"</code> for <code>--example</code>, use <code>NULL</code> to omit),
Junio C Hamano4224f992008-06-23 07:14:081201</p>
1202</li>
1203<li>
1204<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531205<code>int_var</code> is an integer variable,
Junio C Hamano4224f992008-06-23 07:14:081206</p>
1207</li>
1208<li>
1209<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531210<code>str_var</code> is a string variable (<code>char *</code>),
Junio C Hamano4224f992008-06-23 07:14:081211</p>
1212</li>
1213<li>
1214<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531215<code>arg_str</code> is the string that is shown as argument
1216 (e.g. <code>"branch"</code> will result in <code>&lt;branch&gt;</code>).
1217 If set to <code>NULL</code>, three dots (<code>...</code>) will be displayed.
Junio C Hamano4224f992008-06-23 07:14:081218</p>
1219</li>
1220<li>
1221<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531222<code>description</code> is a short string to describe the effect of the option.
1223 It shall begin with a lower-case letter and a full stop (<code>.</code>) shall be
Junio C Hamano4224f992008-06-23 07:14:081224 omitted at the end.
1225</p>
1226</li>
Junio C Hamano4604fe52008-09-19 06:37:101227</ul></div>
Junio C Hamano4224f992008-06-23 07:14:081228</div>
Junio C Hamano9d971152012-12-19 00:43:111229</div>
1230<div class="sect1">
Junio C Hamano4604fe52008-09-19 06:37:101231<h2 id="_option_callbacks">Option Callbacks</h2>
Junio C Hamano4224f992008-06-23 07:14:081232<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:071233<div class="paragraph"><p>The function must be defined in this form:</p></div>
Junio C Hamano4224f992008-06-23 07:14:081234<div class="literalblock">
1235<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531236<pre><code>int func(const struct option *opt, const char *arg, int unset)</code></pre>
Junio C Hamano4224f992008-06-23 07:14:081237</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071238<div class="paragraph"><p>The callback mechanism is as follows:</p></div>
1239<div class="ulist"><ul>
Junio C Hamano4224f992008-06-23 07:14:081240<li>
1241<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531242Inside <code>func</code>, the only interesting member of the structure
1243 given by <code>opt</code> is the void pointer <code>opt-&gt;value</code>.
1244 <code>*opt-&gt;value</code> will be the value that is saved into <code>var</code>, if you
1245 use <code>OPT_CALLBACK()</code>.
1246 For example, do <code>*(unsigned long *)opt-&gt;value = 42;</code> to get 42
1247 into an <code>unsigned long</code> variable.
Junio C Hamano4224f992008-06-23 07:14:081248</p>
1249</li>
1250<li>
1251<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531252Return value <code>0</code> indicates success and non-zero return
1253 value will invoke <code>usage_with_options()</code> and, thus, die.
Junio C Hamano4224f992008-06-23 07:14:081254</p>
1255</li>
1256<li>
1257<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531258If the user negates the option, <code>arg</code> is <code>NULL</code> and <code>unset</code> is 1.
Junio C Hamano4224f992008-06-23 07:14:081259</p>
1260</li>
Junio C Hamano4604fe52008-09-19 06:37:101261</ul></div>
Junio C Hamano4224f992008-06-23 07:14:081262</div>
Junio C Hamano9d971152012-12-19 00:43:111263</div>
1264<div class="sect1">
Junio C Hamano4604fe52008-09-19 06:37:101265<h2 id="_sophisticated_option_parsing">Sophisticated option parsing</h2>
Junio C Hamano4224f992008-06-23 07:14:081266<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:071267<div class="paragraph"><p>If you need, for example, option callbacks with optional arguments
Junio C Hamano4224f992008-06-23 07:14:081268or without arguments at all, or if you need other special cases,
1269that are not handled by the macros above, you need to specify the
Junio C Hamanoc14e6ad2014-10-31 20:25:531270members of the <code>option</code> structure manually.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071271<div class="paragraph"><p>This is not covered in this document, but well documented
Junio C Hamanoc14e6ad2014-10-31 20:25:531272in <code>parse-options.h</code> itself.</p></div>
Junio C Hamano4224f992008-06-23 07:14:081273</div>
Junio C Hamano9d971152012-12-19 00:43:111274</div>
1275<div class="sect1">
Junio C Hamano4604fe52008-09-19 06:37:101276<h2 id="_examples">Examples</h2>
Junio C Hamano4224f992008-06-23 07:14:081277<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:531278<div class="paragraph"><p>See <code>test-parse-options.c</code> and
1279<code>builtin/add.c</code>,
1280<code>builtin/clone.c</code>,
1281<code>builtin/commit.c</code>,
1282<code>builtin/fetch.c</code>,
1283<code>builtin/fsck.c</code>,
1284<code>builtin/rm.c</code>
Junio C Hamano4604fe52008-09-19 06:37:101285for real-world examples.</p></div>
Junio C Hamano4224f992008-06-23 07:14:081286</div>
Junio C Hamano7bd050f2011-09-22 06:32:221287</div>
Junio C Hamano9d971152012-12-19 00:43:111288</div>
Junio C Hamano7bd050f2011-09-22 06:32:221289<div id="footnotes"><hr /></div>
Junio C Hamano3dac5042007-12-15 08:40:541290<div id="footer">
1291<div id="footer-text">
Junio C Hamano2ef0ba32018-01-26 23:13:531292Last updated
Junio C Hamanoc9dd6422020-08-10 23:32:551293 2020-08-10 16:30:08 PDT
Junio C Hamano3dac5042007-12-15 08:40:541294</div>
1295</div>
1296</body>
1297</html>