Browse Source

Update and fix docstrings

Alois Mahdal 6 years ago
parent
commit
100b5bad6c
1 changed files with 37 additions and 12 deletions
  1. 37
    12
      src/saturnin.sh.skel

+ 37
- 12
src/saturnin.sh.skel View File

@@ -199,8 +199,29 @@ saturnin__conf_find() {
199 199
     #
200 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 226
     # If at least one path was found, return zero.  Otherwise, return one,
206 227
     # or more in case of error.
@@ -380,10 +401,10 @@ saturnin__runhook() {
380 401
 
381 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 408
     binpath+="$SATURNIN_LIBEXEC/"
388 409
     binpath+="$SATURNIN_LIBEXEC_PREFIX$subcommand"
389 410
     debug -v binpath
@@ -412,7 +433,11 @@ saturnin__usage() {
412 433
 
413 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 442
     echo -n "$(basename "$0")"
418 443
     test -n "$SATURNIN_APP_TAGLINE" \
@@ -436,7 +461,7 @@ saturnin__wraphook() {
436 461
     # status of the payload command, even if hooks fail.  Ignore post-hook
437 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 465
     saturnin__runhook pre
441 466
     "$@" || return $?
442 467
     es=$?
@@ -463,8 +488,8 @@ _saturnin__conf__merge() {
463 488
     #
464 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 493
     while read -r path;
469 494
     do
470 495
         found=true
@@ -496,8 +521,8 @@ _saturnin__conf__load() {
496 521
     # 'first' strategy, first existing file is printed, with 'join'
497 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 526
     for arg in "$@";
502 527
     do
503 528
         case $arg in
@@ -515,7 +540,7 @@ _saturnin__conf__load() {
515 540
 
516 541
 _saturnin__conf_usage() {
517 542
     #
518
-    # Show usage message and exit
543
+    # Show usage message, passing $@ to mkusage() and exit
519 544
     #
520 545
     PRETTY_USAGE="self=${0##*/} conf" \
521 546
     mkusage "$@"                                                              \