# shellcheck    shell=dash

___x_cmd_cosmo___use(){
    local cosmobin="$1"; [ -n "$cosmobin" ] || N=cosmo M="cosmo bin is required" log:ret:1
    local target_dir="${___X_CMD_ROOT_BIN}"

    [ -f "$target_dir/$cosmobin" ] || {
        ___x_cmd_cosmo___install "$cosmobin" "$target_dir" || return $?
        cosmo:info "Successfully use [cosmobin=$cosmobin] in the current environment"
        return 0
    }
    cosmo:info "Already used [cosmobin=$cosmobin] in this shell environment"
}

___x_cmd_cosmo___unuse(){
    local cosmobin="$1"; [ -n "$cosmobin" ] || N=cosmo M="cosmo bin is required" log:ret:1
    local target="${___X_CMD_ROOT_BIN}/$cosmobin"

    if [ -f "$target" ];then
        ___x_cmd_cmds rm -rf "$target"
        cosmo:info "Success to unuse [cosmobin=$cosmobin] in this session"
        return 0
    fi
    cosmo:warn "Not use [cosmobin=$cosmobin] in current session"
}
