1*2b15cb3dSCy Schubert[+: autogen5 template man :+][+:
2*2b15cb3dSCy SchubertDEFINE mk-synopsis                          :+][+:
3*2b15cb3dSCy Schubert  (out-push-new file-name)                 \:+]
4*2b15cb3dSCy Schubert.Sh SYNOPSIS
5*2b15cb3dSCy Schubert.Nm[+:
6*2b15cb3dSCy Schubert
7*2b15cb3dSCy Schubert  IF (. use-flags)                          :+][+:
8*2b15cb3dSCy Schubert    IF (exist? "long-opts")                 :+]
9*2b15cb3dSCy Schubert.\" Mixture of short (flag) options and long options
10*2b15cb3dSCy Schubert.Op Fl flags
11*2b15cb3dSCy Schubert.Op Fl flag Op Ar value
12*2b15cb3dSCy Schubert.Op Fl \-option-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc
13*2b15cb3dSCy Schubert[+: ELSE no long options:                   :+]
14*2b15cb3dSCy Schubert.Op Fl flags
15*2b15cb3dSCy Schubert.Op Fl flag Op Ar value
16*2b15cb3dSCy Schubert[+: ENDIF
17*2b15cb3dSCy Schubert                                            :+][+:
18*2b15cb3dSCy Schubert  ELIF (exist? "long-opts")
19*2b15cb3dSCy Schubert                                            :+]
20*2b15cb3dSCy Schubert.Op Fl \-option-name
21*2b15cb3dSCy Schubert.Op Fl \-option-name Ar value
22*2b15cb3dSCy Schubert[+:
23*2b15cb3dSCy Schubert
24*2b15cb3dSCy Schubert  ELIF  (not (exist? "argument"))           :+]
25*2b15cb3dSCy Schubert.Op Ar option\-name Ar value
26*2b15cb3dSCy Schubert.Pp
27*2b15cb3dSCy SchubertAll arguments are named options.
28*2b15cb3dSCy Schubert[+:
29*2b15cb3dSCy Schubert  ENDIF                                     :+][+:
30*2b15cb3dSCy Schubert
31*2b15cb3dSCy Schubert  IF (exist? "argument")                    :+][+:
32*2b15cb3dSCy Schubert    argument                                :+][+:
33*2b15cb3dSCy Schubert
34*2b15cb3dSCy Schubert    IF (exist? "reorder-args")              :+]
35*2b15cb3dSCy Schubert.Pp
36*2b15cb3dSCy SchubertOperands and options may be intermixed.  They will be reordered.
37*2b15cb3dSCy Schubert[+: ENDIF                                   :+][+:
38*2b15cb3dSCy Schubert
39*2b15cb3dSCy Schubert  ELIF (or (exist? "long-opts") use-flags)
40*2b15cb3dSCy Schubert
41*2b15cb3dSCy Schubert:+]
42*2b15cb3dSCy Schubert.Pp
43*2b15cb3dSCy SchubertAll arguments must be options.
44*2b15cb3dSCy Schubert[+:
45*2b15cb3dSCy Schubert
46*2b15cb3dSCy Schubert  ENDIF                                     :+][+:
47*2b15cb3dSCy Schubert
48*2b15cb3dSCy Schubert  IF (exist? "main")                        :+][+:
49*2b15cb3dSCy Schubert  CASE main.main-type                       :+][+:
50*2b15cb3dSCy Schubert  == shell-process                          :+]
51*2b15cb3dSCy Schubert.Pp
52*2b15cb3dSCy SchubertThis program will emit text that is expected to be evaluated by
53*2b15cb3dSCy Schuberta Bourne-compatible shell, thus digesting the options for the script.[+:
54*2b15cb3dSCy Schubert
55*2b15cb3dSCy Schubert  == shell-parser                           :+]
56*2b15cb3dSCy Schubert.Pp
57*2b15cb3dSCy SchubertThis program is designed to produce output suitable for inclusion
58*2b15cb3dSCy Schubertinto a shell script that will parse the options described.[+:
59*2b15cb3dSCy Schubert
60*2b15cb3dSCy Schubert  == for-each                               :+]
61*2b15cb3dSCy Schubert.Pp
62*2b15cb3dSCy SchubertThe operands that this program operates on may be specified either
63*2b15cb3dSCy Schuberton the command line or read from standard input, one per line.
64*2b15cb3dSCy SchubertIn that input, leading and trailing white space is stripped,
65*2b15cb3dSCy Schubertblank lines are ignored[+:
66*2b15cb3dSCy Schubert
67*2b15cb3dSCy Schubert    IF (define comment-char (get "comment-char" "#"))
68*2b15cb3dSCy Schubert       (> (string-length comment-char) 1)  \:+]
69*2b15cb3dSCy Schubert and lines beginning with the character
70*2b15cb3dSCy Schubert.I [+: (substring comment-char 1 0):+]
71*2b15cb3dSCy Schubertare treated as comments[+:
72*2b15cb3dSCy Schubert    ENDIF :+].[+:
73*2b15cb3dSCy Schubert
74*2b15cb3dSCy Schubert    IF (exist? "interleaved")               :+]
75*2b15cb3dSCy SchubertOptions may be interleaved with operands both on the command
76*2b15cb3dSCy Schubertline and when operands are read from standard input.[+:
77*2b15cb3dSCy Schubert    ENDIF  interleaved
78*2b15cb3dSCy Schubert
79*2b15cb3dSCy Schubert:+]
80*2b15cb3dSCy SchubertStandard input may not be a terminal.[+:
81*2b15cb3dSCy Schubert
82*2b15cb3dSCy Schubert  ESAC  main-type                           :+][+:
83*2b15cb3dSCy Schubert  ENDIF  main exists                        :+]
84*2b15cb3dSCy Schubert.Pp
85*2b15cb3dSCy Schubert[+:
86*2b15cb3dSCy Schubert
87*2b15cb3dSCy SchubertFOR explain   "\n.Pp\n"                     :+][+:
88*2b15cb3dSCy Schubert  (get "explain" "")                        :+][+:
89*2b15cb3dSCy SchubertENDFOR                                      :+][+:
90*2b15cb3dSCy Schubert
91*2b15cb3dSCy Schubert(out-pop)                                   :+][+:
92*2b15cb3dSCy SchubertENDDEF mk-synopsis                          :+]
93