36 lines
		
	
	
		
			640 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			640 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/usr/bin/env bash
 | ||
| 
 | ||
| main() {
 | ||
|   if [[ $(type -t "⚡️$1") == "function" ]]; then
 | ||
|     ⚡️$1
 | ||
|   else
 | ||
|     ⚡️help
 | ||
|   fi
 | ||
| }
 | ||
| 
 | ||
| ⚡️help() {
 | ||
|   _help-line "Show this list" "$@"
 | ||
|   echo Usage: "$0" SUBCOMMAND
 | ||
|   echo
 | ||
|   echo "Available subcommands:"
 | ||
|   for subcommand in $(_subcommands); do
 | ||
|     if [[ $(type ⚡️$subcommand) =~ _help-line ]]; then
 | ||
|       printf "\t%-20s - %s\n" "$subcommand" "$(⚡️$subcommand help-line)"
 | ||
|     else
 | ||
|       printf "\t%-20s" $subcommand
 | ||
|     fi
 | ||
|   done
 | ||
| }
 | ||
| 
 | ||
| _subcommands() {
 | ||
|   compgen -c ⚡️ | cut -c3-
 | ||
| }
 | ||
| 
 | ||
| _help-line() {
 | ||
|   if [[ "$#" == 2 && "$2" == "help-line" ]]; then
 | ||
|     echo "$1" && exit 0
 | ||
|   fi
 | ||
| }
 | ||
| 
 | ||
| main "$@"
 |