# shellcheck shell=dash

___x_cmd_top___main(){
    [ "$#" -gt 0 ] ||   set -- -e --battery --show_table_scroll_position

    local op="$1";  shift

    # Adding some ai features ...
    case "$op" in
        -h|--help)      ___x_cmd help -m top        "$@" ; return 0 ;;
        ,|--coco)       ___x_cmd_top___coco         "$@" ;;

        btm)            ___x_cmd_top___app          "$@" ;;
        --)             command top                 "$@" ;;

        *)              ___x_cmd_top___cmd "$op"    "$@" ; return 1 ;;
    esac
}

___x_cmd_top___cmd(){
    if ___x_cmd_is_stdout2tty; then
        ___x_cmd_top___app "$@"
    else
        command top
    fi
}

___x_cmd_top___app(){
    if ___x_cmd_hascmd btm; then
        command btm "$@"
    else
        ___x_cmd snap --run btm "$@"
    fi
}

___x_cmd_top___coco(){
    :
    # Trying to analysis the current system status
}

