From 829ad08a7bf52db458c3abc4afaec6961b4007a3 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 5 Sep 2020 00:26:29 -0400 Subject: [PATCH] Added help option -h. --- audiogame-manager.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 554fd12..fb0191a 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -57,6 +57,15 @@ checklist() { exit 0 } +help() { + echo -e "Usage:\n" + echo "With no arguments, open the game launcher." + for i in "${!command[@]}" ; do + echo "-${i}: ${command[${i}]}" + done | sort + exit 0 +} + install_wine_bottle() { local bottle="${game,,}" bottle="${bottle//[[:space:]]/-}" @@ -249,17 +258,21 @@ if [[ $# -eq 0 ]]; then fi # Array of command line arguments -command=( - "c" # Check wine environment - "i" # Install games - "m" # Manually handle install screens - "r" # Remove a game +declare -A command=( + [c]="Check your system for necessary components." + [h]="This help screen." + [i]="Install games." + [m]="Manually handle install screens instead of using xdotools." + [r]="Remove a game. This will delete all game data." ) -while getopts "${command[*]//[[:space:]]/}" i ; do +# Convert the keys of the associative array to a format usable by getopts +args="${!command[*]}" +args="${args//[[:space:]]/}" +while getopts "${args}" i ; do case "$i" in c) checklist;; - h) show_help;; + h) help;; i) game_installer;; m) manualInstall="true";; r) game_removal;;