# shellcheck shell=dash

xrc:mod:lib     df      __darwin    __linux

___x_cmd_df___main(){
    [ "$#" -gt 0 ] ||   set -- --exec
    local op="$1"; shift
    case "$op" in
        -h|--help)      ___x_cmd help -m df;    return $?   ;;
        --exec)         ___x_cmd_df___exec        "$@"      ;;
        *)              ___x_cmd_df___exec "$op"  "$@"      ;;
    esac


}

___x_cmd_df___exec(){
    local x_
    ___x_cmd os name_
    case "$x_" in
        darwin)         x_=darwin   ;;
        *)              x_=linux    ;;
    esac

    local fmt=auto
    local numeric=

    while [ $# -gt 0 ]; do
        case "$1" in
            -n|--numeric)   numeric=1       ;;
            -c|--csv)       fmt=csv         ;;
            -t|--tsv)       fmt=tsv         ;;
            -r|--raw)       fmt=raw;        ;;
            --auto|--app)   fmt="${1#--}"   ;;
            *)              break
        esac
        shift
    done

    ___x_cmd_df___"${x_}"___"${fmt}"
}


___x_cmd_df___raw_sort(){
    {
        read -r line;
        printf "%s\n" "$line"
        sort -k 1
    }
}
