# shellcheck shell=dash

___x_cmd_slash_get(){
    case "$1" in
        -h|--help) ___x_cmd help -m slash get; return ;;
    esac

    local name="$1"
    [ -n "$name" ] || N=slash M="Please provide slash command name" log:ret:64

    ___x_cmd_slash_check___inner || return $?

    local cfgfp="$___X_CMD_SLASH_CONFIG"
    [ -f "$cfgfp" ] || N=slash M="Not found config file" log:ret:1

    local found=0
    local cur_name=""
    while IFS= read -r line; do
        case "$line" in
            [!\ ]*:*)
                [ "$found" = 1 ] && return 0
                cur_name="${line%:}"
                if [ "$cur_name" = "$name" ]; then
                    found=1
                    printf "%s\n" "$line"
                fi
                ;;
            "  "*)
                [ "$found" = 1 ] && printf "%s\n" "$line"
                ;;
        esac
    done < "$cfgfp"
    [ "$found" = 1 ] || N=slash M="Not found -> $name" log:ret:1
}
