diff --git a/lyrics/lyrics b/lyrics/lyrics index 0ae51b4..be3962d 100755 --- a/lyrics/lyrics +++ b/lyrics/lyrics @@ -165,11 +165,13 @@ while getopts "f:a:s:uvh" opt; do ;; a) artist="true" + if [[ "$(echo "$@" | grep -Eo "\-s")" == "-s" ]];then song="true";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary) ;; s) song="true" + if [[ "$(echo "$@" | grep -Eo "\-a")" == "-a" ]];then artist="true";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary) ;; - :) echo "Option -$OPTARG requires an argument." >&2file="false" + :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac @@ -191,13 +193,21 @@ elif [[ $# == "1" ]]; then fi fi -if ! $artist || ! $song;then { echo "Error: the -a and the -s flag must be used to fetch lyrics."; exit 1; }; fi -song=$(echo "$@" | grep -Eo "\-s [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-s//g | sed s/-//g | sed s/^" "//g) -if [[ $song == "" ]];then { echo "Error: song could not be parsed from input."; exit 1; };fi -artist=$(echo "$@" | grep -Eo "\-a [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-a//g | sed s/-//g | sed s/^" "//g) -if [[ $artist == "" ]];then { echo "Error: artist could not be parsed from input."; exit 1; };fi -getConfiguredClient || exit 1 -if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1;fi -checkInternet || exit 1 -getLyrics "$artist" "$song" || exit 1 -printLyrics +if ($artist && ! $song) || ($song && ! $artist);then + echo "Error: the -a and the -s flag must be used to fetch lyrics." + exit 1 +elif $artist && $song;then + song=$(echo "$@" | grep -Eo "\-s [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-s//g | sed s/-//g | sed s/^" "//g) + if [[ $song == "" ]];then { echo "Error: song could not be parsed from input."; exit 1; };fi + artist=$(echo "$@" | grep -Eo "\-a [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-a//g | sed s/-//g | sed s/^" "//g) + if [[ $artist == "" ]];then { echo "Error: artist could not be parsed from input."; exit 1; };fi + getConfiguredClient || exit 1 + if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1;fi + checkInternet || exit 1 + getLyrics "$artist" "$song" || exit 1 + printLyrics +else + { clear; echo "You shouldnt be here but maaaaaaybeee you slipped passed me, learn to use the tool!"; sleep 5; clear;} + usage + exit 1 +fi