Skip to content

Instantly share code, notes, and snippets.

@n4bb12
Last active January 27, 2024 15:58
Show Gist options
  • Save n4bb12/7a2306003586dd4ec3f27984700fe740 to your computer and use it in GitHub Desktop.
Save n4bb12/7a2306003586dd4ec3f27984700fe740 to your computer and use it in GitHub Desktop.
Bash-based CLI template
#
# 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