#compdef gukhanmun

autoload -U is-at-least

_gukhanmun() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'--generate-completion=[Write a shell completion script to stdout and exit without converting. Use shell redirection to save it; cannot be combined with conversion options]:GENERATE_COMPLETION:(bash zsh fish powershell nushell)' \
'-o+[Output file to write to; writes to standard output when omitted. When the same path as INPUT, the file is replaced atomically]:PATH:_files' \
'--output=[Output file to write to; writes to standard output when omitted. When the same path as INPUT, the file is replaced atomically]:PATH:_files' \
'-f+[Input/output format.  Inferred from the input file extension when omitted (text/html for .html/.htm, text/markdown for .md/.markdown, text/plain otherwise); falls back to text/plain when reading from standard input. Accepted values\: text/plain, text/html, text/markdown.  MIME parameters are accepted for text/markdown; use "text/markdown; variant=GFM" to enable GitHub Flavored Markdown (tables, footnotes, strikethrough, task lists).  Unrecognised parameters are ignored]:MIME:' \
'--format=[Input/output format.  Inferred from the input file extension when omitted (text/html for .html/.htm, text/markdown for .md/.markdown, text/plain otherwise); falls back to text/plain when reading from standard input. Accepted values\: text/plain, text/html, text/markdown.  MIME parameters are accepted for text/markdown; use "text/markdown; variant=GFM" to enable GitHub Flavored Markdown (tables, footnotes, strikethrough, task lists).  Unrecognised parameters are ignored]:MIME:' \
'-p+[Language variant preset.  ko-kr (default) enables the bundled Standard Korean Dictionary (標準國語大辭典), NIKL loanword examples, and the initial sound law (頭音法則). ko-kp leaves loanwords disabled and enables the bundled Open Korean Dictionary 북한어 category and disables the initial sound law, targeting North Korean orthography]:PRESET:(ko-kr ko-kp)' \
'--preset=[Language variant preset.  ko-kr (default) enables the bundled Standard Korean Dictionary (標準國語大辭典), NIKL loanword examples, and the initial sound law (頭音法則). ko-kp leaves loanwords disabled and enables the bundled Open Korean Dictionary 북한어 category and disables the initial sound law, targeting North Korean orthography]:PRESET:(ko-kr ko-kp)' \
'*-d+[Path to a user-supplied dictionary file (.gukfst or .gukcdb).  May be repeated; later dictionaries take priority over earlier ones and over every bundled dictionary]:PATH:_files' \
'*--dictionary=[Path to a user-supplied dictionary file (.gukfst or .gukcdb).  May be repeated; later dictionaries take priority over earlier ones and over every bundled dictionary]:PATH:_files' \
'*--reference-dictionary=[Additional reference dictionary (.gukfst or .gukcdb). May be repeated]:PATH:_files' \
'*--loanword-dictionary=[Additional loanword dictionary (.gukfst or .gukcdb). May be repeated]:PATH:_files' \
'--source-policy=[Cooperation policy; ordered restores the original dictionary-order policy]:SOURCE_POLICY:(reference-authorized reference-first loanword-first ordered)' \
'-s+[Segmentation strategy for hanja-containing spans.  lattice (default) chooses the best path through all dictionary matches.  eager greedily takes the longest match at each cursor for lower overhead]:SEGMENTATION:(lattice eager)' \
'--segmentation=[Segmentation strategy for hanja-containing spans.  lattice (default) chooses the best path through all dictionary matches.  eager greedily takes the longest match at each cursor for lower overhead]:SEGMENTATION:(lattice eager)' \
'--numerals=[Numeral conversion strategy for fallback hanja numerals. smart (default) chooses Arabic only for common numeric forms; hangul-phonetic emits hangul annotations; positional-arabic normalizes digit-only runs; additive-arabic normalizes place-marker numerals]:NUMERALS:(hangul-phonetic positional-arabic additive-arabic smart)' \
'--numeral-strategy=[Numeral conversion strategy for fallback hanja numerals. smart (default) chooses Arabic only for common numeric forms; hangul-phonetic emits hangul annotations; positional-arabic normalizes digit-only runs; additive-arabic normalizes place-marker numerals]:NUMERALS:(hangul-phonetic positional-arabic additive-arabic smart)' \
'--recovery=[Reader error recovery policy.  strict (default) stops at recoverable reader errors.  lenient preserves recoverable bad regions and continues; currently this is meaningful for malformed HTML fragments]:RECOVERY:(strict lenient)' \
'(--punctuation-profile)--punctuation=[Output punctuation preset, independent of the language preset]:PUNCTUATION:(preserve modern traditional traditional-vertical)' \
'(--punctuation)--punctuation-profile=[JSON punctuation profile, with optional base and per-role overrides]:PATH:_files' \
'-r+[Controls how hanja annotations appear in the output.  hangul-only (default for most presets) emits hangul, adding parenthesized hanja only when disambiguation requires it.  hangul-hanja-parens always emits 한글(漢字).  hanja-hangul-parens always emits 漢字(한글).  ruby-on-hangul and ruby-on-hanja emit a \`ruby\` element with hangul or hanja as the base; scopes that disallow inline markup fall back to parens.  original keeps the source hanja, adding a hangul gloss only where required]:RENDERING:(hangul-only hangul-hanja-parens hanja-hangul-parens ruby-on-hangul ruby-on-hanja original)' \
'--rendering=[Controls how hanja annotations appear in the output.  hangul-only (default for most presets) emits hangul, adding parenthesized hanja only when disambiguation requires it.  hangul-hanja-parens always emits 한글(漢字).  hanja-hangul-parens always emits 漢字(한글).  ruby-on-hangul and ruby-on-hanja emit a \`ruby\` element with hangul or hanja as the base; scopes that disallow inline markup fall back to parens.  original keeps the source hanja, adding a hangul gloss only where required]:RENDERING:(hangul-only hangul-hanja-parens hanja-hangul-parens ruby-on-hangul ruby-on-hanja original)' \
'--hanja-variant-set=[Variant set used wherever output keeps hanja]:HANJA_VARIANT_SET:(as-dictionary shinjitai kanxi simplified asahimoji)' \
'--original-gloss=[Gloss form used by the original renderer.  parens (default) emits 漢字(한글); ruby emits a \`ruby\` element with hanja as the base and hangul as the rt gloss, falling back to parens in scopes that disallow inline markup.  Only valid with --rendering original]:ORIGINAL_GLOSS:(parens ruby)' \
'--disambiguation=[Homophone disambiguation context.  off disables homophone marking; per-block resets at block scopes; per-section resets at headings; per-document uses one window for the full input]:DISAMBIGUATION:(off per-block per-section per-document)' \
'--homophone-detection=[Homophone detection strategy.  context-local glosses a reading only when a different-meaning homophone appears within the disambiguation window; dictionary-wide also glosses readings shared by other dictionary entries]:HOMOPHONE_DETECTION:(context-local dictionary-wide)' \
'--first-occurrence=[Context for clearing repeated dictionary presentation requirements. off leaves every occurrence as marked by dictionaries and directives]:FIRST_OCCURRENCE:(off per-block per-section per-document)' \
'*--directives=[Path to a UTF-8 TSV directive file.  The header must be \`action<TAB>pattern<TAB>kind\`; actions are require-hanja, require-hangul, or skip-annotation, and kind is literal or glob.  May be repeated]:PATH:_files' \
'*--require-hanja=[Require visible hanja for a literal hanja form.  May be repeated]:HANJA:' \
'*--require-hanja-glob=[Require visible hanja for hanja forms matched by a CLI glob pattern. The pattern supports \`*\` for any sequence and \`?\` for one character]:PATTERN:' \
'*--require-hangul=[Require a hangul gloss for a literal hanja form.  May be repeated]:HANJA:' \
'*--require-hangul-glob=[Require a hangul gloss for hanja forms matched by a CLI glob pattern. The pattern supports \`*\` for any sequence and \`?\` for one character]:PATTERN:' \
'*--skip-annotation=[Collapse annotation rendering for a literal hanja form.  May be repeated]:HANJA:' \
'*--skip-annotation-glob=[Collapse annotation rendering for hanja forms matched by a CLI glob pattern.  The pattern supports \`*\` for any sequence and \`?\` for one character]:PATTERN:' \
'*--html-preserve-class=[Preserve any HTML element whose \`class\` attribute contains the given CSS class.  Matching elements and their descendants pass through the converter untouched, in addition to the built-in preserved tags (\`pre\`, \`code\`, \`kbd\`, \`script\`, \`style\`, \`textarea\`) and the inherited \`lang\` rule.  May be repeated.  Only valid with \`--format text/html\`]:CLASS:' \
'*--html-preserve-attr=[Preserve any HTML element matching an attribute predicate.  Accepts either \`KEY\` (matches when the attribute is present with any value or none, including as a boolean attribute) or \`KEY=VALUE\` (matches when the attribute is present with the exact value).  Matched elements and their descendants pass through untouched.  May be repeated.  Only valid with \`--format text/html\`]:KEY[=VALUE]:' \
'*--markdown-frontmatter-convert=[Also convert selected YAML front matter values, addressed by a JSONPath expression (for example \`\$.hero.tagline\` or \`\$.hero.actions\[*\].text\`). Each matched string scalar is converted from mixed script to hangul; non-string matches are left untouched.  May be repeated.  The whole front matter block is reformatted on output, but only matched values change.  When given without a leading YAML front matter block, a warning is logged and only the Markdown body is converted.  Only valid with \`--format text/markdown\`]:JSONPATH:' \
'--reference-only[Exclude independent loanword choices, retaining reference-authorized forms. The ordered policy ignores this filter]' \
'-S[Disable every bundled dictionary selected by the preset]' \
'--no-bundled-dictionaries[Disable every bundled dictionary selected by the preset]' \
'(-S --no-bundled-dictionaries --no-loanwords)--loanwords[Enable NIKL loanword examples (default for ko-kr, opt-in for ko-kp)]' \
'--no-loanwords[Disable only NIKL loanword examples, retaining other preset dictionaries]' \
'-i[Enable the initial sound law (頭音法則), overriding the preset default]' \
'--initial-sound-law[Enable the initial sound law (頭音法則), overriding the preset default]' \
'--dueum[Enable the initial sound law (頭音法則), overriding the preset default]' \
'-I[Disable the initial sound law (頭音法則), overriding the preset default]' \
'--no-initial-sound-law[Disable the initial sound law (頭音法則), overriding the preset default]' \
'--no-dueum[Disable the initial sound law (頭音法則), overriding the preset default]' \
'--no-collapse-parens[Keep redundant parenthetical reading annotations instead of collapsing them.  By default an explicit gloss such as 庫間(곳간) or 곳간(庫間) is collapsed to show both scripts once; this flag preserves the explicit parenthetical text instead]' \
'-v[Enable debug-level logging to stderr.  Equivalent to RUST_LOG=debug when RUST_LOG is not already set.  Use RUST_LOG for finer control (e.g. RUST_LOG=trace)]' \
'--verbose[Enable debug-level logging to stderr.  Equivalent to RUST_LOG=debug when RUST_LOG is not already set.  Use RUST_LOG for finer control (e.g. RUST_LOG=trace)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::input -- Input file to read from; reads from standard input when omitted:_files' \
&& ret=0
}

(( $+functions[_gukhanmun_commands] )) ||
_gukhanmun_commands() {
    local commands; commands=()
    _describe -t commands 'gukhanmun commands' commands "$@"
}

if [ "$funcstack[1]" = "_gukhanmun" ]; then
    _gukhanmun "$@"
else
    compdef _gukhanmun gukhanmun
fi
