Selaa lähdekoodia

Do not show all modules/functions by default (add `-a` option)

Alois Mahdal 9 vuotta sitten
vanhempi
commit
ae5e29ff80
2 muutettua tiedostoa jossa 19 lisäystä ja 3 poistoa
  1. 18
    2
      src/bin/shellfu-get.skel
  2. 1
    1
      tests/shellfu_api/TF_RUN

+ 18
- 2
src/bin/shellfu-get.skel Näytä tiedosto

@@ -26,7 +26,15 @@ do_lsfun() {
26 26
     #
27 27
     # List functions from module $1 or all
28 28
     #
29
-    shellfu _list_functions "$modspec"
29
+    local modspec="$1"
30
+    if $show_hidden;
31
+    then
32
+        shellfu _list_functions "$modspec"
33
+    else
34
+        shellfu _list_functions "$modspec" \
35
+          | grep -v ^_ \
36
+          | grep -v \\._
37
+    fi
30 38
 }
31 39
 
32 40
 do_lsmod() {
@@ -34,7 +42,13 @@ do_lsmod() {
34 42
     # List available modules
35 43
     #
36 44
     local modspec="$1"
37
-    shellfu _list_modules "$modspec"
45
+    if $show_hidden;
46
+    then
47
+        shellfu _list_modules "$modspec"
48
+    else
49
+        shellfu _list_modules "$modspec" \
50
+          | grep -v ^_
51
+    fi
38 52
 }
39 53
 
40 54
 do_path() {
@@ -54,11 +68,13 @@ do_version() {
54 68
 
55 69
 main() {
56 70
     local action="usage"
71
+    local show_hidden=false
57 72
     local include=""
58 73
     while true; do case "$1" in
59 74
         --version)                  do_version;         exit ;;
60 75
         --version-semver)           do_semver;          exit ;;
61 76
         -I|--include)               include="$2";       shift 2 || usage ;;
77
+        -a|--all)                   show_hidden=true;   shift ;;
62 78
         -d|--debug)                 SHELLFU_DEBUG=true; shift ;;
63 79
         catfun|lsfun|lsmod|path)    action="$1";        shift; break ;;
64 80
         *) usage  ;;

+ 1
- 1
tests/shellfu_api/TF_RUN Näytä tiedosto

@@ -4,7 +4,7 @@
4 4
 . "$TF_DIR/include/tools.sh"
5 5
 
6 6
 shellfu_get_sorted() {
7
-    shellfu-get "$1" | LC_ALL=C sort
7
+    shellfu-get -a "$1" | LC_ALL=C sort
8 8
 }
9 9
 
10 10
 tf_enum_subtests() {