|
@@ -135,6 +135,44 @@ usage_is() {
|
135
|
135
|
}
|
136
|
136
|
|
137
|
137
|
|
|
138
|
+mkhelp() {
|
|
139
|
+ #
|
|
140
|
+ # Echo out help text
|
|
141
|
+ #
|
|
142
|
+ # mkhelp line...
|
|
143
|
+ #
|
|
144
|
+ # Each argument as a separate line. This makes it easy to
|
|
145
|
+ # print out bigger amount of text and still keep your script
|
|
146
|
+ # relatively clean:
|
|
147
|
+ #
|
|
148
|
+ # mkhelp "line1" \
|
|
149
|
+ # "line2" \
|
|
150
|
+ # "line3" \
|
|
151
|
+ # "line4"
|
|
152
|
+ #
|
|
153
|
+ # By default, will exit with status *FFOO_EXIT_OK*, you
|
|
154
|
+ # can use `-e STATUS` to specify other number.
|
|
155
|
+ #
|
|
156
|
+ # Use `-E` to prevent exiting; in that case, the status
|
|
157
|
+ # that would be fed to `exit` will be used as exit status
|
|
158
|
+ # of this function.
|
|
159
|
+ #
|
|
160
|
+ # Use "--" to delimit end of arguments processed by mkhelp
|
|
161
|
+ #
|
|
162
|
+ local es=$FFOO_EXIT_OK
|
|
163
|
+ local doexit=true
|
|
164
|
+ while true; do case "$1" in
|
|
165
|
+ -e) es="$2"; shift 2 ;;
|
|
166
|
+ -E) doexit=false; shift ;;
|
|
167
|
+ --) shift; break ;;
|
|
168
|
+ *) break ;;
|
|
169
|
+ esac done
|
|
170
|
+ _pretty__echo -l "$@"
|
|
171
|
+ $doexit && exit "$es"
|
|
172
|
+ return "$es"
|
|
173
|
+}
|
|
174
|
+
|
|
175
|
+
|
138
|
176
|
think() {
|
139
|
177
|
#
|
140
|
178
|
# If verbose is on, think loud
|
|
@@ -235,7 +273,7 @@ _pretty__echo() {
|
235
|
273
|
frontend="$(_pretty__cut_stack '^_pretty__echo' | head -1 )"
|
236
|
274
|
caller="$(
|
237
|
275
|
_pretty__cut_stack \
|
238
|
|
- '^_pretty_|^warn$|^debug_pipe$|^debug$|^die$|^usage$|^usage_is$|^think$' \
|
|
276
|
+ '^_pretty_|^warn$|^debug_pipe$|^debug$|^die$|^mkhelp$|^usage$|^usage_is$|^think$' \
|
239
|
277
|
| head -1
|
240
|
278
|
)"
|
241
|
279
|
test "$frontend" == "main" && frontend=$(basename $0)
|
|
@@ -254,6 +292,7 @@ _pretty__echo() {
|
254
|
292
|
case $frontend in
|
255
|
293
|
debug) ;&
|
256
|
294
|
die) ;&
|
|
295
|
+ mkhelp) ;&
|
257
|
296
|
think) ;&
|
258
|
297
|
usage_is) ;&
|
259
|
298
|
warn)
|
|
@@ -320,6 +359,12 @@ _pretty__echo_trace() {
|
320
|
359
|
}
|
321
|
360
|
|
322
|
361
|
|
|
362
|
+_pretty__echo_help() {
|
|
363
|
+ local oldverbose="$FFOO_VERBOSE"
|
|
364
|
+ think -l "$@"
|
|
365
|
+ FFOO_VERBOSE=$oldverbose
|
|
366
|
+}
|
|
367
|
+
|
323
|
368
|
_pretty__echo_usage() {
|
324
|
369
|
#
|
325
|
370
|
# Print each argument as usage pattern
|