# Eryn Wells <eryn@erynwells.me>
# vim: set ft=zsh:

function bool {
    if [[ "$1" =~ '^-?[0-9]+$' ]]; then
        if (( $1 == 0 )); then
            echo "no"
            return 1
        else
            echo "yes"
            return 0
        fi
    fi

    local lowercase_value=${(L)1}

    if [[ "$lowercase_value" == "yes" || "$lowercase_value" == "true" ]]; then
        echo "yes"
        return 0
    fi

    if [[ "$lowercase_value" == "no" || "$lowercase_value" == "false" ]]; then
        echo "no"
        return 1
    fi

    echo "no"
    return 1
}

bool "$@"
