Last active
January 27, 2024 15:58
-
-
Save n4bb12/7a2306003586dd4ec3f27984700fe740 to your computer and use it in GitHub Desktop.
Bash-based CLI template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This makes the above functions work as CLI commands. | |
# | |
if [ -n "$1" ] && (type $1 2>&1) | grep -i function > /dev/null; then | |
$@ | |
else | |
echo "Unknown command: $1" | |
commands=$(compgen -A function | tr '\n' ' ') | |
echo "All commands: $commands" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment