# shellcheck shell=dash
___x_cmd_scotty_nv(){
    param:void
    # ___x_cmd_runmode_allow_manual || {
    #     scotty:info "It should be used in manual mode"
    #     return 1
    # }

    if ___x_cmd_is_stdout2tty; then
        ___x_cmd_scotty_info | ___x_cmd y2j | ___x_cmd ja 2c .name .info | ___x_cmd csv app --header name,info --preview info --table-width 20%
    else
        ___x_cmd_scotty_info
    fi
}

# info

___x_cmd_scotty_info(){
    param:void
    # what is the version of x-cmd you are using
    # what is the system you are using
    local x_=

    _v_x_cmd="$( ___x_cmd_scotty_info_xcmd | ___x_cmd_scotty_info_mask)"
    _v_shell="$___X_CMD_SHELL"

    x_=; ___x_cmd awk version_
    _v_awk="$x_"

    _v_sed="$(      ___x_cmd_cmds sed --version     2>&1 )"
    _v_grep="$(     ___x_cmd_cmds grep --version    2>&1 )"
    _v_find="$(     ___x_cmd_cmds find --version    2>&1 )"
    _v_busybox="$(  ___x_cmd_cmds busybox --help    2>&1 )"
    _v_curl="$(     ___x_cmd_cmds curl --version    2>&1 )"
    _v_wget="$(     ___x_cmd_cmds wget --version    2>&1 )"
    _v_yq="$(       ___x_cmd_cmds yq --version      2>&1 )"
    _v_jq="$(       ___x_cmd_cmds jq --version      2>&1 )"
    _v_fzf="$(      ___x_cmd_cmds fzf --version     2>&1 )"

    _v_release="$(  ___x_cmd os release )"



    # Is your system overloaded ?
    # Is your system running out of memory ?
    # Is your home folder running out of disk space ?
    # Is your tmp folder running out of disk space ?

    local NO_COLOR="$NO_COLOR"
    { ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_manual; } || NO_COLOR=1
    ___x_cmd cawk \
        -E NO_COLOR,_v_x_cmd,_v_shell,_v_awk,_v_sed,_v_grep,_v_find,_v_busybox,_v_curl,_v_wget,_v_yq,_v_jq,_v_fzf,_v_release \
        -f "$___X_CMD_ROOT_MOD/scotty/lib/awk/info.awk"
}

___x_cmd_scotty_info_xcmd(){
    xrc:mod:lib pkg     envvar

    printf "___X_CMD_PKG_VERSION:       %s\n"               "$___X_CMD_PKG_VERSION"
    printf "___X_CMD_WEBSRC_REGION:     %s\n"               "$___X_CMD_WEBSRC_REGION"
    printf "___X_CMD_LANG:              %s\n"               "$___X_CMD_LANG"

    printf "\n==== x-cmd version ====\n"
    ___x_cmd version

    printf "\n==== root ls ====\n"
    ___x_cmd root ls

    printf "\n==== boot rc ====\n"
    ___x_cmd boot rc ls
}

___x_cmd_scotty_info_mask(){
    ___x_cmd_cmds awk -v home="$HOME" '{
        gsub(home, "<<HOME-STRING>>", $0)
        print
    }'
}
