diff --git a/wled b/wled index 7e1bf1b..5493e9e 100755 --- a/wled +++ b/wled @@ -6,9 +6,28 @@ # Author: Shy # License: CC0 +COMMAND="wled" +VERSION="0.0.1" + print_usage() { - echo "Usage: $0 f(nordcenter)|w(ohnzimmer) on|off|1-17|list" - echo " $0 f(nordcenter)|w(ohnzimmer) b(rightness) 1-255" + echo "\ +Usage: $COMMAND -f|-w [on|off] + $COMMAND -f|-w [1-17|list] + $COMMAND -f|-w -b [1-255]" +} + +print_help() { + print_usage + echo " +host selection: + -f,--fnordcenter select fnordcenter + -w,--wohnzimmer select wohnzimmer + +commands: + on|off switch on/off + [1-17] switch preset + l, list list presets + -b,--brightness [1-255] set brightness" } curl_cmd() { @@ -17,14 +36,18 @@ curl_cmd() { # Parse host argument. case "$1" in - ""|-h|--h) # Missing host parameter. - print_usage + ""|-h|--help) # Missing host parameter. + print_help exit 0 ;; - f|fnordcenter) + -v|--version) + echo "wled.sh version $VERSION" + exit 0 + ;; + -f|--fnordcenter) wled_host='wled-fnordcenter.local' ;; - w|wohnzimmer) + -w|--wohnzimmer) wled_host='wled-wohnzimmer.local' ;; *) # Unknown host parameter. @@ -42,7 +65,7 @@ case "$2" in off) # Switch off. api_resp=$(curl_cmd --json '{"on":false}' "http://$wled_host/json") ;; - b|brightness) # Set brightness. + -b|--brightness) # Set brightness. if test -z "$3"; then echo "Error: missing parameter for brightness." >&2 exit 1