# Author:       Li Junhao       l@x-cmd.com         #xrc
# shellcheck    shell=sh        disable=SC3043

# Section: main

xrc instance ldict # for ___X_CMD_LDICT_SEP and ___X_CMD_LDICT_KVSEP var

___x_cmd_dict(){
    local O="${O:-DEFAULT}"

    if [ "${1#@}" != "$1" ]; then
        O="___X_BASH_DICT_${1#@}"
        shift
    fi

    case "$1" in
        new | del | make | free | get | put | scope | \
        remove | clear | drop | dropr | grep | grepr | iter | \
        load | load_json | dump | json | \
        size | has | is_empty )
            local op="$1"; shift;
            "___x_cmd_dict_$op" "$@" ;;
        -h|--help)
            x help -m dict 1>&2
            return 1 ;;
        *)    : help ;;
    esac
}

xrc:mod dict/lib/pipe dict/lib/share

if [ -n "${BASH_VERSION}" ]; then
    case "${BASH_VERSION}" in
        3*|4.0*|4.1*)
            xrc:mod dict/lib/str
            # . ./lib/str
            ;;
        *)
            xrc:mod dict/lib/bash4
            ;;
    esac
elif [ -n "${ZSH_VERSION}" ]; then
    xrc:mod dict/lib/zsh
else
    xrc:mod dict/lib/str
fi

xrc setmain ___x_cmd_dict

## EndSection
