Explorar el Código

Update and fix docstrings

Alois Mahdal hace 6 años
padre
commit
100b5bad6c
Se han modificado 1 ficheros con 37 adiciones y 12 borrados
  1. 37
    12
      src/saturnin.sh.skel

+ 37
- 12
src/saturnin.sh.skel Ver fichero

199
     #
199
     #
200
     # Find all existing instances of sub-path $1 on $SATURNIN_CONF_PATH
200
     # Find all existing instances of sub-path $1 on $SATURNIN_CONF_PATH
201
     #
201
     #
202
-    # Go through all elements of $SATURNIN_CONF_PATH, looking for file on
203
-    # sub-path $1.  Print each existing path, ignore rest.
202
+    # Usage:
203
+    #
204
+    #     saturnin__conf_find SUBPATH
205
+    #
206
+    # Go through all elements of $SATURNIN_CONF_PATH, looking for file or
207
+    # directory, whose path is formed by joining SUBPATH to element of
208
+    # $SATURNIN_CONF_PATH.  Print each existing path, ignore rest.
209
+    #
210
+    # For example, with following setup:
211
+    #
212
+    #     SATURNIN_CONF_PATH=foo:bar:baz
213
+    #     mkdir -p foo/one bar/one
214
+    #     mkdir -p bar/two/slashes
215
+    #
216
+    # call
217
+    #
218
+    #     saturnin__conf_find one
219
+    #
220
+    # would print `foo/one` and `bar/one`, while
221
+    #
222
+    #     saturnin__conf_find two/slashes
223
+    #
224
+    # would print `bar/two/slashes`.
204
     #
225
     #
205
     # If at least one path was found, return zero.  Otherwise, return one,
226
     # If at least one path was found, return zero.  Otherwise, return one,
206
     # or more in case of error.
227
     # or more in case of error.
380
 
401
 
381
 saturnin__runsc() {
402
 saturnin__runsc() {
382
     #
403
     #
383
-    # Run subcommand $SATURNIN_SUBCOMMAND
404
+    # Run subcommand $1 with arguments $2..
384
     #
405
     #
385
-    local subcommand="$1"; shift
386
-    local binpath   # path to subcommand's binary
406
+    local subcommand="$1"; shift    # subcommand to run
407
+    local binpath                   # path to subcommand's binary
387
     binpath+="$SATURNIN_LIBEXEC/"
408
     binpath+="$SATURNIN_LIBEXEC/"
388
     binpath+="$SATURNIN_LIBEXEC_PREFIX$subcommand"
409
     binpath+="$SATURNIN_LIBEXEC_PREFIX$subcommand"
389
     debug -v binpath
410
     debug -v binpath
412
 
433
 
413
 saturnin__version() {
434
 saturnin__version() {
414
     #
435
     #
415
-    # Print version info
436
+    # Print human-readable version info
437
+    #
438
+    # Basic version info is already stored in $SATURNIN_APP_VERSION,
439
+    # this function prints more descriptive paragraph including Saturnin's
440
+    # own version.
416
     #
441
     #
417
     echo -n "$(basename "$0")"
442
     echo -n "$(basename "$0")"
418
     test -n "$SATURNIN_APP_TAGLINE" \
443
     test -n "$SATURNIN_APP_TAGLINE" \
436
     # status of the payload command, even if hooks fail.  Ignore post-hook
461
     # status of the payload command, even if hooks fail.  Ignore post-hook
437
     # if payload command failed.
462
     # if payload command failed.
438
     #
463
     #
439
-    local es=0      # exit status of thid function
464
+    local es=0      # exit status of this function
440
     saturnin__runhook pre
465
     saturnin__runhook pre
441
     "$@" || return $?
466
     "$@" || return $?
442
     es=$?
467
     es=$?
463
     #
488
     #
464
     # Take paths and applying merge strategy, load file(s)
489
     # Take paths and applying merge strategy, load file(s)
465
     #
490
     #
466
-    local path
467
-    local found=false
491
+    local path          # every path
492
+    local found=false   # 'true' if we got any path
468
     while read -r path;
493
     while read -r path;
469
     do
494
     do
470
         found=true
495
         found=true
496
     # 'first' strategy, first existing file is printed, with 'join'
521
     # 'first' strategy, first existing file is printed, with 'join'
497
     # strategy, all existing files are printed.
522
     # strategy, all existing files are printed.
498
     #
523
     #
499
-    local arg es
500
-    es=0
524
+    local arg       # each passed argument
525
+    local es=0      # exit status of this function
501
     for arg in "$@";
526
     for arg in "$@";
502
     do
527
     do
503
         case $arg in
528
         case $arg in
515
 
540
 
516
 _saturnin__conf_usage() {
541
 _saturnin__conf_usage() {
517
     #
542
     #
518
-    # Show usage message and exit
543
+    # Show usage message, passing $@ to mkusage() and exit
519
     #
544
     #
520
     PRETTY_USAGE="self=${0##*/} conf" \
545
     PRETTY_USAGE="self=${0##*/} conf" \
521
     mkusage "$@"                                                              \
546
     mkusage "$@"                                                              \