Browse Source

Add usage message to saturnin-conf

Alois Mahdal 8 years ago
parent
commit
0979beb943
1 changed files with 20 additions and 15 deletions
  1. 20
    15
      src/shellfu/saturnin.sh

+ 20
- 15
src/shellfu/saturnin.sh View File

@@ -94,9 +94,9 @@ saturnin__conf() {
94 94
         -K:*)   ig_mode=$1; ig_query=$2; shift 2; break ;;
95 95
         -S:*)   ig_mode=$1; ig_query=""; shift 1; break ;;
96 96
         -P:*)   ig_mode=$1; ig_query=""; shift 1; break ;;
97
-        .*:*)   warn "bad syntax: $*"; return 2 ;;
97
+        .*:*)   warn "bad syntax: $*"; _saturnin__conf_usage ;;
98 98
         *.*:*)  ig_mode=-e; ig_query=$1; shift 1; break ;;
99
-        *)      warn "bad syntax: $*"; return 2 ;;
99
+        *)      warn "bad syntax: $*"; _saturnin__conf_usage ;;
100 100
     esac done
101 101
     test -n "$ig_mode" || { warn "could not determine inigrep mode"; _saturnin__conf_usage; }
102 102
     debug -v ig_limit ig_query ig_mode Strategy
@@ -364,11 +364,14 @@ _saturnin__conf_usage() {
364 364
     #
365 365
     #
366 366
     #
367
-    mkusage "[options] [-e] SECTION.KEY [FILE...]"                             \
368
-            "[options] -r SECTION.KEY [FILE...]"                               \
369
-            "[options] -K SECTION [FILE...]"                                   \
370
-            "[options] -P [FILE...]"                                           \
371
-            "[options] -S [FILE...]"                                           \
367
+    PRETTY_USAGE="self=${0##*/} conf" \
368
+    mkusage "[options] [-e] SECTION.KEY [FNAME]"                               \
369
+            "[options] -r SECTION.KEY [FNAME]"                                 \
370
+            "[options] -K SECTION [FNAME]"                                     \
371
+            "[options] -P FNAME"                                               \
372
+            "[options] -S FNAME"                                               \
373
+        --                                                                     \
374
+            "Use inigrep to query config files."                               \
372 375
         -o                                                                     \
373 376
             "-j     join all files before applying query"                      \
374 377
             "-1     ensure single line is returned"                            \
@@ -376,15 +379,17 @@ _saturnin__conf_usage() {
376 379
             "-e     use normal mode (default)"                                 \
377 380
             "-r     use raw mode (preserves RHS whitespace and some comments)" \
378 381
             "-K     list available keys in SECTION"                            \
379
-            "-S     list available sections"                                   \
380
-            "-P     list available keypaths (SECTION.KEY)"                     \
382
+            "-S     list available sections in FNAME"                          \
383
+            "-P     list available keypaths (SECTION.KEY) in FNAME"            \
381 384
         --                                                                     \
382
-            "Uses inigrep to query config files.  SECTION is section name (may"\
383
-            "contain dots itself, KEY is key name.  Unless FILE is provided,"  \
384
-            "filename is inferred from SECTION (eg. 'foo.ini' if 'foo.bar' was"\
385
-            "sectionname) and searched in folders given in SATURNIN_CONF_PATH."\
386
-            "If FILE contains slash, no search is done and just single FILE is"\
387
-            "used instead."
385
+            "FNAME is filename, which is then searched on all paths specified" \
386
+            "in SATURNIN_CONF_PATH and depending on -j parameter, first one"   \
387
+            "wins or all are joined.  If FNAME contains slash, this search is" \
388
+            "not done and FNAME is taken as path to file that is then queried."\
389
+            ""                                                                 \
390
+            "If FNAME is omitted, it is inferred from SECTION (e.g. .'foo.ini'"\
391
+            "if 'foo.bar' was section name; note that section name may contain"\
392
+            "dot)."
388 393
 }
389 394
 
390 395
 _saturnin__nl2colon() {