-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanpage.tpl
262 lines (222 loc) · 7.12 KB
/
manpage.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
{( -*- nroff -*-
autogen5 template script=updater
)}
{(#
1999-06-26 original version, Jim Van Zandt <[email protected]>
1999-06-28 modified to be template Bruce Korb <[email protected]>
1999-07-04 nroff tweaks, Jim Van Zandt <[email protected]>
2001-08-25 converted to autogen5 template, Jim Van Zandt <[email protected]>
)}/^.\\" @synopsis@$/,/^.\\" @@$/{
if (!synopsis_updated) {
print ".\\\" @synopsis@\n\
.B {(
IF (exist? "prog_file_name") )}{(prog_file_name)}{(
ELSE)}{(prog_name)}{(
ENDIF)}{(
IF (exist? "flag.value") )}{(
IF (exist? "long_opts") )}{(
# * * * * * * * * * * * * * * * * * * * * * * * * *
#
# Mixture of short (flag) options and long options
#
)}\n\
.\\\" Mixture of short (flag) options and long options\n\
.RB [ -\\fIflag\\fP \" [\\fIvalue\\fP]]... [\" --\\fIopt-name\\fP [ = \"| ]\\fIvalue\\fP]...\"{(
ELSE )}{(
# * * * * * * * * * * * * * * * * * * * * * * * * *
#
# Short (flag) options only
#
)}
.\\\" Short (flag) options only\n\
.RB [ -\\fIflag\\fP \" [\\fIvalue\\fP]]...\"{(
ENDIF )}{(
ELIF (exist? "long_opts") )}{(
# * * * * * * * * * * * * * * * * * * * * * * * * *
#
# Long options only
#
)}\n\
.\\\" Long options only\n\
.RB [ --\\fIopt-name\\fP [ = \"| ] \\fIvalue\\fP]...\"{(
ELIF (not (exist? "argument") )}{(
# * * * * * * * * * * * * * * * * * * * * * * * * *
#
# All arguments are named options.
#
)}
.\\\" All arguments are named options.\n\
.RI [ opt-name \"[\\fB=\\fP\" value ]]...\n\
.PP\n\
All arguments are named options.{(
ELSE )}{(
(error "Named option programs cannot have arguments") )}{(
ENDIF )}{(
IF (exist? "argument") )}
.br\n\
.in +8\n\
{(argument)}{(
ENDIF )}";
print ".\\\" @@"
}
synopsis_updated=1;
next;
}
/^.\\" @options@$/,/^.\\" @@$/{
if (!options_updated) {
print ".\\\" @options@";
{(
# When there are no flag characters and long options are disallowed,
the program options are all named options and they are handled
without the marker character (hyphen). )}{(
FOR flag
)}{(
# Skip the documentation options!
#
)}{(
IF (not (exist? "documentation")) )}print "\
.TP{(
IF (exist? "value") )}{(
IF (exist? "long_opts") )}{(
# * * * * * * * * * * * * * * * * * * * *
*
* The option has a flag value (character) AND
* the program uses long options
*
)}\n\
.BR -{(value)}{(
IF (not (exist? "arg_name")) )} \", \" --{(
ELSE )} \" \\fI{(arg_name)}\\fP, \" --{(
ENDIF )}{(% name (string-tr! "%s" "A-Z_^" "a-z--") )}{(
IF (exist? "arg_name") )}{(
IF ( = (len "flag_arg") 0 )} [ ={(
ELSE )} \" \" {(
ENDIF )}\\fI{(arg_name)}\\fP{(
IF ( = (len "flag_arg") 0 )} ]{(
ENDIF )}{(
ENDIF)}{(
ELSE )}{(
# * * * * * * * * * * * * * * * * * * * *
*
* The option has a flag value (character) BUT
* the program does _NOT_ use long options
*
)}\n\
.BR -{(value)}{(
IF (exist" "arg_name) )}{(
IF ( = (len "flag_arg") 0 )}[{(
ENDIF )} \"\\fI{(arg_name)}\\fP{(
IF ( = (len "flag_arg") 0 )}\"]\"{(
ENDIF )}{(
ENDIF)}{(
ENDIF )}{(
ELSE value does not exist -- named option only )}{(
IF (not (exist? "long_opts") )}{(
# * * * * * * * * * * * * * * * * * * * *
*
* The option does not have a flag value (character).
* The program does _NOT_ use long options either.
* Special magic: All arguments are named options.
*
)}\n\
.BR {((string-downcase (string-tr! "name" "#_^" "#--")))}{(
IF arg_name _exist)} {(
IF ( = (len "flag_arg") 0) )} [ ={(
ELSE )} \"\" {(
ENDIF )}\\fI{(arg_name)}\\fP{(
IF (= (len "flag_arg") 0) )}]{(
ENDIF )}{(
ENDIF)}{(
ELSE )}{(
# * * * * * * * * * * * * * * * * * * * *
*
* The option does not have a flag value (character).
* The program, instead, only accepts long options.
*
)}\n\
.BR --{((string-downcase (string-tr! "name" "#_^" "#--")))}{(
IF (exist? "arg_name"))} \"{(
IF ( = (len "flag_arg") 0 ) )}[{(
ENDIF )}\" \"=\\fI{(arg_name)}\\fP{(
IF ( = (len "flag_arg") 0 ) )}]{(
ENDIF )}\"{(
ENDIF)}{(
ENDIF )}{(
ENDIF )}\n\
{(descrip)}{(
IF (or (exist? "min")
(exist? "max")
(exist? "enabled")
(exist? "no_preset")
(exist? "setable")
(exist? "equivalence")
(exist? "flags_must")
(exist? "flags_cant")) )}.\n\
Special attributes apply to this option.\n\
See the invocation section in the info document.{(
ENDIF)}\n\
{( IF (exist? "doc"))}.sp\n\
{( ENDIF)}{(
# SED
-e convert @code into \fB...\fP phrases
-e convert @file into \fI...\fP phrases
-e convert @var into \fB...\fP phrases
-e Remove the '@' prefix from curly braces
-e Indent example regions
-e Delete example command
-e Replace "end example" command with ".br"
-e Replace "@*" command with ".br"
-e Add "\n\" to the end of each line.
NB: backslashes are interpreted four times: by AutoGen, sed, awk
and nroff. Thus, for nroff to see one backslash, use eight (8)!!
))}{(
doc (shell (printf "sed \
-e's;@code{\\([^}]*\\)\};\\\\\\\\fB\\1\\\\\\\\fP;g' \
-e's;@file{\\([^}]*\\)\};\\\\\\\\fI\\1\\\\\\\\fP;g' \
-e's;@var{\\([^}]*\\)\};\\\\\\\\fB\\1\\\\\\\\fP;g' \
-e's/@\\([{}]\\)/\\1/' \
-e'/@ *example/,/@ *end *example/s/^/ /' \
-e'/^ *@ *example/d' \
-e's/^ *@ *end *example/.br/' \
-e's/^@\\*/.br/' \
-e's/$/\\\\n\\\\/' <<'_EOF_'\n%s\n_EOF_")) )}{(
ENDIF (not (exist? "documentation")) )}.br";
{(
ENDFOR flag
)}print "\
.TP\n\
.BR {(IF (exist? "flag.value") )}\\-? \", \" --{(
ELIF (exist? "long_opt") )}--{(ENDIF)}help\n\
Display usage information and exit.\n\
.TP\n\
.BR {(IF (exist? "flag.value") )}-! \", \" --{(
ELIF (exist? "long_opt") )}--{(ENDIF)}more-help\n\
Extended usage information passed thru pager.{(
IF (exist? "homerc") )}\n\
.TP\n\
.BR {(IF (exist? "flag.value") )}-> \" \\fIrcfile\\fP, --\" {(
ELIF (exist? "long_opt") )}--{(ENDIF)}save-opts \"[=\\fIrcfile\\fP] \n\
Save the option state to \\fIrcfile\\fP.\n\
.TP\n\
.BR {(IF (exist? "flag.value") )}-< \" \\fIrcfile\\fP, --\" {(
ELIF (exist? "long_opt") )}--{(ENDIF)}load-opts \"=\\fIrcfile\\fP\"\n\
Load options from \\fIrcfile\\fP.\n\
.TP\n\
.BR --no-load-opts\n\
Disable loading options from an rc file.{(
ENDIF)}{(
IF (exist? "version") )}\n\
.TP\n\
.BR {(IF (exist? "flag.value") )}\\-v \" [\" v | c | n \"], \" --{(
ELIF (exist? "long_opt") )}--{(ENDIF)}version [ =v | c | n ]\n\
Output version of program and exit. The default mode is `v', a simple\n\
version. The `c' mode will print copyright information and `n' will\n\
print the full copyright notice.{(
ENDIF
)}";
print ".\\\" @@"
}
options_updated=1;
next;
}
{print}