# shellcheck shell=dash disable=SC2016

___x_cmd_font_nerd_info(){
    local X_help_cmd=""; X_help_cmd='x help -m font nerd info' help:arg:parse

    local NO_COLOR="$NO_COLOR"
    if ! ___x_cmd_is_stdout2tty || ! ___x_cmd_runmode_allow_manual; then
        [ -n "$FORCE_COLOR" ] || NO_COLOR=1
    fi

    local name="${1:?'Provide font name, e.g: FiraCode'}"
    ___x_cmd_font_nerd___tsv_raw | \
        ___x_cmd_cmds awk -v FS="\t" -v name="$name"  -v NO_COLOR="$NO_COLOR" '
            function print_fmt ( k, v ){
                if (NO_COLOR != 1)   printf("\033[32m%s\033[0m: %s\n",   k,v)
                else                 printf("%s: %s\n",   k,v)
            }
            $1 == name {
                print_fmt("Name", $1)
                print_fmt("Family", $2)
                print_fmt("License", $3)
                print_fmt("Version", $4)

                if (NO_COLOR != 1)   printf("\033[32m%s\033[0m: \033[4mhttps://www.programmingfonts.org/#%s\033[0m\n",   "Preview", $5)
                else                 printf("%s: https://www.programmingfonts.org/#%s\n",   "Preview", $5)

                print_fmt("Description", $6)
                print_fmt("IsMonospaced", $7)
                found = 1
            }
            END {
                if (!found) {
                    printf("- Error: Not Found %s Font Data\n",   name) > "/dev/stderr"
                    exit 1
                }
            }
        '
}
