Browse Source

Do not force empty line before indent mode

This was not intended,  only indentation was intended (no pun indented).

Seriously, omitting the newline makes the -i mode more useful as we can
now use syntax like:

    mkusage "topic" \
      --
      "topics:" \
      "${topics[@]}"

That is much less code, especially if the list we wanted to include is
already in array.
Alois Mahdal 6 years ago
parent
commit
f58cde84b2

+ 1
- 1
src/include-bash/pretty.sh View File

@@ -503,7 +503,7 @@ _pretty__echo_usage() {
503 503
         case $esc:$arg in
504 504
             0:--) shift; mode=plain;  esc=1; echo                ;;
505 505
             0:-c) shift; mode=indent; esc=1; echo; echo commands: ;;
506
-            0:-i) shift; mode=indent; esc=1; echo                ;;
506
+            0:-i) shift; mode=indent; esc=1                      ;;
507 507
             0:-o) shift; mode=indent; esc=1; echo; echo options: ;;
508 508
             0:-u) shift; mode=usage;  esc=1                      ;;
509 509
             *)  esc=0

+ 9
- 10
tests/pretty_basic/TF_RUN View File

@@ -263,8 +263,7 @@ mkoracle() {
263 263
             echo '  load - load a file or something'
264 264
             echo '  save - save a file or something'
265 265
             echo ''
266
-            echo 'here is some data'
267
-            echo ''
266
+            echo 'other items:'
268 267
             echo '  data1'
269 268
             echo '  data2'
270 269
             echo '  data3'
@@ -284,11 +283,10 @@ mkoracle() {
284 283
             echo '  load - load a file or something'
285 284
             echo '  save - save a file or something'
286 285
             echo ''
287
-            echo 'here is some data'
288
-            echo ''
289
-            echo '  data1'
290
-            echo '  data2'
291
-            echo '  data3'
286
+            echo 'other items:'
287
+            echo '  item1'
288
+            echo '  item2'
289
+            echo '  item3'
292 290
             echo ''
293 291
             echo "and that's all folks!"
294 292
             echo ''
@@ -314,9 +312,10 @@ mkoracle() {
314 312
             echo '  wrap_mkusage_i [-d] load [-f file]'
315 313
             echo '  wrap_mkusage_i [-d] save [-f file]'
316 314
             echo ''
317
-            echo '  data1'
318
-            echo '  data2'
319
-            echo '  data3'
315
+            echo 'other items:'
316
+            echo '  item1'
317
+            echo '  item2'
318
+            echo '  item3'
320 319
             ;;
321 320
         oracle/v1_d1/wrap_mkusage_o.stderr)
322 321
             echo 'usage:'

+ 1
- 1
tests/pretty_basic/test/wrap_mkusage_all View File

@@ -11,7 +11,7 @@ usage() {
11 11
             "-f file    some file" \
12 12
          -c "load - load a file or something" \
13 13
             "save - save a file or something" \
14
-         -- "here is some data" \
14
+         -- "other items:" \
15 15
          -i "data1" "data2" "data3" \
16 16
          -- "and that's all folks!"
17 17
 }

+ 2
- 2
tests/pretty_basic/test/wrap_mkusage_allw View File

@@ -12,8 +12,8 @@ usage() {
12 12
             "-f file    some file" \
13 13
          -c "load - load a file or something" \
14 14
             "save - save a file or something" \
15
-         -- "here is some data" \
16
-         -i "data1" "data2" "data3" \
15
+         -- "other items:" \
16
+         -i "item1" "item2" "item3" \
17 17
          -- "and that's all folks!"
18 18
 }
19 19
 

+ 2
- 1
tests/pretty_basic/test/wrap_mkusage_i View File

@@ -7,7 +7,8 @@ shellfu import pretty
7 7
 usage() {
8 8
     mkusage "[-d] load [-f file]" \
9 9
             "[-d] save [-f file]" \
10
-         -i "data1" "data2" "data3"
10
+         -- "other items:" \
11
+         -i "item1" "item2" "item3"
11 12
 }
12 13
 
13 14
 usage