From 3740abbf39c2535146025f094ab586eeac5681c5 Mon Sep 17 00:00:00 2001 From: pabera <1260686+pabera@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:05:50 +0100 Subject: [PATCH] fix: outsource example_usage for 1-line install --- installation/components/setup_hifiberry.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/installation/components/setup_hifiberry.sh b/installation/components/setup_hifiberry.sh index ff4bffbd6..a91b825fb 100644 --- a/installation/components/setup_hifiberry.sh +++ b/installation/components/setup_hifiberry.sh @@ -19,11 +19,20 @@ declare -A hifiberry_map=( ) # 1-line installation +example_usage() { + for key in "${!hifiberry_map[@]}"; do + description="${hifiberry_map[$key]}" + echo "$key) $description" + done + echo "Example usage: ./${script_name} enable hifiberry-dac" +} + if [ $# -ge 1 ]; then if { ([ "$1" != "enable" ] && [ "$1" != "disable" ]) || ([ "$1" -= "enable" ] && [ $# -ge 2 ]); }; then echo "Error: Invalid provided. -Usage: ./${script_name} [optional] +Usage: ./${script_name} where can be 'enable' or 'disable'" + example_usage exit 1 fi @@ -33,11 +42,7 @@ where can be 'enable' or 'disable'" return 0;; *) echo "'$2' is not a valid option. You can choose from:" - for key in "${!hifiberry_map[@]}"; do - description="${hifiberry_map[$key]}" - echo "$key) $description" - done - echo "Example usage: ./${script_name} enable hifiberry-dac" + example_usage exit 1 ;; esac