# shellcheck disable=SC2016

___x_cmd_ccmd_x_cmd_advise_json(){
    ___x_cmd_cmds_cat <<A
{
    "help": {
        "#desc":"Show help for command"
    },
    "clear": {
        "#desc":"Clear cache"
    },
    "setup": {
        "#desc":"Set cache storage location"
    },
    "teardown": {
        "#desc":"Teardown storage location"
    } ,
    "invalidate": {
        "#desc":"invalidate the current cache"
    }
}
A
}


___x_cmd_ccmd_help(){
    local IFS=

    if [ $# -ne 0 ]; then
        printf "%s
------------------\n" "$@"
    fi

    printf '
ccmd -- cache the command result.

Please visit following websites for more information:
    https://gitee.com/x-bash/cache
    https://github.com/x-bash/cache

SYNOPSIS
    ccmd [expiration, n[smhdw] ] [cache-filepath] -- <command> [...arguments]

DESCRIPTION
    About expiration, pattern like "n[smhdw]"
        n is number, "smhdw" is unit.
        s       second
        m       minute (60 seconds)
        h       hour (60 minutes)
        d       day (24 hours)
        w       week (7 days)

    If no unit provided, the default unit is "d"

    Example:
        Do NOT use cache. Update the command result NOW
            > ccmd 0 -- curl https://x-bash.gitee.io/boot
        Use cache if updated within 1 day. (default)
            > ccmd -- curl https://x-bash.gitee.io/boot
        Use cache if updated within 3 day.
        Cache the command result in future 3 days
            > ccmd 3 -- curl https://x-bash.gitee.io/boot
        Use cache if updated within 3 minutes.
            > ccmd 3m -- curl https://x-bash.gitee.io/boot
        Use cache if updated within 3 hours.
            > ccmd 3h ~/cache -- curl https://x-bash.gitee.io/boot
        Cache the command result in the file "~/cache" regardless whether the command fails
            > ccmd -- curl https://x-bash.gitee.io/boot || true

'
}
