summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-06-14 16:10:00 +0200
committerSimon Rettberg2019-06-14 16:10:00 +0200
commit00330d80a0982229016171cb7b872d110b899c96 (patch)
treedca22cbd893c2c6c70797e0f4917f26af4c6ee01
parentFix typo (diff)
downloadslx-tools-00330d80a0982229016171cb7b872d110b899c96.tar.gz
slx-tools-00330d80a0982229016171cb7b872d110b899c96.tar.xz
slx-tools-00330d80a0982229016171cb7b872d110b899c96.zip
Exclude functions with wrong prefix; list available functions
Invoking slx-tools without arguments lists available functions now.
-rwxr-xr-xmake.sh11
-rw-r--r--slx-tools.template1
2 files changed, 10 insertions, 2 deletions
diff --git a/make.sh b/make.sh
index 5f32249..2c6fe5e 100755
--- a/make.sh
+++ b/make.sh
@@ -12,6 +12,7 @@ set -e
DEFS=
+FUNCTIONS=
for file in modules/**/*.inc; do
name="${file#modules/}"
@@ -24,12 +25,18 @@ for file in modules/**/*.inc; do
rm -f -- slx-tools
exit 1
fi
+ FUNCTIONS="${FUNCTIONS%, }"'\n '
for var in $( grep -oP '^[a-z0-9_]+\s*\(\)' "$file" | grep -oE '^[a-z0-9_]+' ); do
- echo "Found $var"
+ if ! [[ "$var" == "$name"* ]]; then
+ echo "- IGNORING $var"
+ continue
+ fi
+ echo "+ Including $var"
DEFS+="$var() { . \$BASE/$file; $var "'"$@"; }\n'
+ FUNCTIONS+="$var, "
done
done
-sed "s#%DEFS%#${DEFS}#;s#^BASE=.*\$#BASE='$BASE'#" slx-tools.template > slx-tools
+sed "s#%DEFS%#${DEFS}#;s#%FUNCTIONS%#${FUNCTIONS%, }#;s#^BASE=.*\$#BASE='$BASE'#" slx-tools.template > slx-tools
chmod +x slx-tools
diff --git a/slx-tools.template b/slx-tools.template
index 0fb99b3..7adf6c0 100644
--- a/slx-tools.template
+++ b/slx-tools.template
@@ -17,6 +17,7 @@ if [ "${0##*/}" = "slx-tools" ]; then
"$@"
else
echo "slx-tools [function] [args...]"
+ echo "Available functions:%FUNCTIONS%"
fi
else
: