Browse Source

Add command to list imported modules

Alois Mahdal 6 years ago
parent
commit
480e8e666d

+ 6
- 0
src/shellfu.sh.skel View File

196
             shellfu __debug "found module file: $mpath"
196
             shellfu __debug "found module file: $mpath"
197
             shellfu _read_directive "module-version" "$mpath"
197
             shellfu _read_directive "module-version" "$mpath"
198
             ;;
198
             ;;
199
+        ls_imported)
200
+            #
201
+            # Print list of modules already imported
202
+            #
203
+            echo "$__SHELLFU_IMPORTED" | tr : \\n
204
+            ;;
199
 
205
 
200
         _do_import)
206
         _do_import)
201
             #
207
             #

+ 15
- 1
tests/shellfu_import/TF_RUN View File

11
     echo "try_import_var_fn"
11
     echo "try_import_var_fn"
12
     echo "import_var_fn_bash"
12
     echo "import_var_fn_bash"
13
     echo "import_var_fn_bash_hint"
13
     echo "import_var_fn_bash_hint"
14
+    echo "ls_imported"
14
 }
15
 }
15
 
16
 
16
 ignored() {
17
 ignored() {
51
     # File _ignored_ is used as list of tokens to always
52
     # File _ignored_ is used as list of tokens to always
52
     # remove from the info.
53
     # remove from the info.
53
     #
54
     #
55
+    test "$name" == ls_imported && return 0
54
     local target="$1"
56
     local target="$1"
55
     printf "
57
     printf "
56
         {
58
         {
88
         try_import_fn) echo 'shellfu try_import mod_f'          ;;
90
         try_import_fn) echo 'shellfu try_import mod_f'          ;;
89
         try_import_var) echo 'shellfu try_import mod_v'         ;;
91
         try_import_var) echo 'shellfu try_import mod_v'         ;;
90
         try_import_var_fn) echo 'shellfu try_import mod_v_f'    ;;
92
         try_import_var_fn) echo 'shellfu try_import mod_v_f'    ;;
93
+        ls_imported) echo 'shellfu import mod_v_f'
94
+                     echo 'shellfu try_import mod_v_f_bash'
95
+                     echo 'shellfu import mod_v'
96
+                     echo 'shellfu import mod_v_f'
97
+                     echo 'shellfu ls_imported'                 ;;
91
     esac
98
     esac
92
 }
99
 }
93
 
100
 
119
     #
126
     #
120
     local name="$1"
127
     local name="$1"
121
     mktscript "$name" > "$name.sh"
128
     mktscript "$name" > "$name.sh"
129
+
122
     mkdir -p result
130
     mkdir -p result
123
     chmod +x "$name.sh"
131
     chmod +x "$name.sh"
124
-    env -i PATH="$PATH" SHELLFU_DIR="$SHELLFU_DIR" ./"$name.sh"
132
+    env -i PATH="$PATH" SHELLFU_DIR="$SHELLFU_DIR" ./"$name.sh" \
133
+        >"result/$name.out" 2>"result/$name.err"
134
+    test "$name" == ls_imported && {
135
+        diff -u "oracle/$name.out" "result/$name.out" || return 1
136
+        diff -u "oracle/$name.err" "result/$name.err" || return 1
137
+        return 0
138
+    }
125
     comm -13 "$name.before" "$name.after" > "result/$name.new"
139
     comm -13 "$name.before" "$name.after" > "result/$name.new"
126
     # i.e. lines introduced by import ^^
140
     # i.e. lines introduced by import ^^
127
     diff -u "oracle/$name.new" "result/$name.new"
141
     diff -u "oracle/$name.new" "result/$name.new"

+ 1
- 0
tests/shellfu_import/oracle/ls_imported.err View File

1
+shellfu: cannot find module: mod_v_f_bash

+ 2
- 0
tests/shellfu_import/oracle/ls_imported.out View File

1
+mod_v_f
2
+mod_v