31 lines
568 B
Bash
Executable File
31 lines
568 B
Bash
Executable File
#!/bin/bash
|
|
|
|
|
|
# Sheep: Shepard a file full of functions.
|
|
# Call one directly or load them as a library.
|
|
#
|
|
function sheep {
|
|
if [[ "${BASH_SOURCE[1]}" != "${0}" ]]; then
|
|
: # Do Nothing: no-op command
|
|
else
|
|
# Run if loaded directly.
|
|
source ../.env
|
|
|
|
CALL=$1
|
|
shift
|
|
|
|
# Call Method
|
|
[[ "$(type -t $CALL)" == "function" ]] && {
|
|
"$CALL" "$@"
|
|
} || {
|
|
[[ -z "$CALL" ]] && {
|
|
echo -e "Available Functions\n"
|
|
ret="$(declare -Fp)"
|
|
ret="${ret//declare -f/}"
|
|
echo "${ret//sheep/}"
|
|
}
|
|
}
|
|
fi
|
|
}
|
|
|