Skip to content

Commit

Permalink
fix: outsource example_usage for 1-line install
Browse files Browse the repository at this point in the history
  • Loading branch information
pabera committed Jan 12, 2024
1 parent 8e584b7 commit 3740abb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions installation/components/setup_hifiberry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} <status> <hifiberry-board>[optional]
Usage: ./${script_name} <status> <hifiberry-board>
where <status> can be 'enable' or 'disable'"
example_usage
exit 1
fi

Expand All @@ -33,11 +42,7 @@ where <status> 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
Expand Down

0 comments on commit 3740abb

Please sign in to comment.