# shellcheck shell=sh disable=SC3043

# author:       Li Junhao           l@x-cmd.com

___x_cmd_ui_tf(){
    arg:init x 'x ui -h'
    arg:1:nonempty
    local op="$1"
    local text="$2"
    [ -n "$text" ] || M="Please provide text" arg:ret:64
    shift 2
    case "$op" in
        true|success)               ___x_cmd_ui_tf__draw "- ✓" "$(___x_cmd_ui_style green )" "$text"  ;; # "✔"
        false|error|failure)        ___x_cmd_ui_tf__draw "- X" "$(___x_cmd_ui_style error)" "$text" ;;
        skipped|*)                  ___x_cmd_ui_tf__draw "-" "$(___x_cmd_ui_style yellow)" "$text" ;;
    esac

    local arg= ; for arg in "$@"; do
        ___X_CMD_UI_TF_INDENT="${___X_CMD_UI_TF_INDENT}  " ___x_cmd_ui_tf skipped "$arg"
    done
}

___x_cmd_ui_tf__draw(){
    local icon="$1"
    local NO_COLOR="$NO_COLOR"
    { ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_chatty ;} || NO_COLOR=1

    [ "$NO_COLOR" = 1 ] || {
        local c_s="${2}"
        local c_e; c_e="$(___x_cmd_ui_style end)"
    }
    shift 2
    printf "${___X_CMD_UI_TF_INDENT}${c_s}%s$c_e %s\n" "$icon" "$*"
}

# ___x_cmd_ui_tf "false" "Sorry, your..."
# ___x_cmd_ui_tf "?" "Type, dddddd..."
# ___x_cmd_ui_tf "true" "Created, repository Markdown is 123456 light \n weight and easy-to-use syntax for styling all forms of writing on the GitHub platform."

# x ui tf "false" "Creating repo success"
# ___X_CMD_UI_TF_INDENT="  " x ui tf skipped "repo_id: 202213232"
# ___X_CMD_UI_TF_INDENT="  " x ui tf skipped "url: url"
# ___X_CMD_UI_TF_INDENT="  " x ui tf skipped "repo_owner: repo_owner"

# x ui tf true "msg" "Id: Id" "Name: name" "Path: dir" "Url: url" "Visibility: visibility"

# . ./.x-cmd/dev/truefalse/a
