# shellcheck shell=dash

# has different situation:
# 1. no token, no user dir
# 2. has token, but token is invalid
___x_cmd_hub_account_logout(){
    local X_help_cmd='___x_cmd_hub___help account logout'
    help:arg:parse

    local token; token="$(___x_cmd_hub_u_get_token)" || return
    hub:debug "Logout with token=$token"

    {
        local x_=; ___x_cmd_hub_u_userdir_ me || return 1
        ___x_cmd rmrf "$x_"
        ___x_cmd_hub_token_rm "${token}"
    } >/dev/null 2>&1 || true

    {
        ___x_cmd_hub_cfg --unset token
        ___x_cmd_hub_cfg --unset cc_token
    } || {
         ___x_cmd_ui_tf false "Failed to unset token use cfgy"
        return 1
    }
    ___x_cmd_ui_tf true "Logout Successfully"
}