Feat: Help options

This commit is contained in:
Narvin Singh 2021-01-01 23:47:30 -05:00
parent a4e443d946
commit 3b675b0da0

16
avds
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
USAGE=" USAGE="
USAGE: avds <mod_list> [<when>] [<repeat>] USAGE: avds <mod_list|-h|-[-]help> [<when>] [<repeat>]
mod_list mod_list
A comma or space separated list of modules to request that A comma or space separated list of modules to request that
@ -19,6 +19,12 @@ USAGE: avds <mod_list> [<when>] [<repeat>]
EXAMPLES: EXAMPLES:
Any of these will display this help message.
avds -h
avds -help
avds --help
If there are volume and backlight modules named 'vol' and 'bl' that If there are volume and backlight modules named 'vol' and 'bl' that
update the volume and backlight statuses, send a requst to update update the volume and backlight statuses, send a requst to update
both of those statuses immediately. both of those statuses immediately.
@ -52,6 +58,14 @@ if [[ "$#" -lt 1 || "$#" -gt 3 ]]; then
fi fi
IFS=', ' read -r -a mods <<< "$1" IFS=', ' read -r -a mods <<< "$1"
# Check if the user needs help
# shellcheck disable=SC2128
if [[ "${mods}" =~ ^(-h|-(-)?help)$ ]]; then
printf '%s' "${USAGE}" 1>&2
exit 0
fi
when="${2:-0}" when="${2:-0}"
repeat="$3" repeat="$3"