#compdef iwe

autoload -U is-at-least

_iwe() {
    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[@]}" : \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_iwe_commands" \
"*::: :->iwe" \
&& ret=0
    case $state in
    (iwe)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:iwe-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" : \
'-t+[Template name from config]:TEMPLATE:_default' \
'--template=[Template name from config]:TEMPLATE:_default' \
'-c+[Content for the new document]:CONTENT:_default' \
'--content=[Content for the new document]:CONTENT:_default' \
'-i+[Behavior when file already exists\: suffix (append -1, -2, etc.), override (overwrite), skip (do nothing)]:IF_EXISTS:(suffix override skip)' \
'--if-exists=[Behavior when file already exists\: suffix (append -1, -2, etc.), override (overwrite), skip (do nothing)]:IF_EXISTS:(suffix override skip)' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-e[Open created file in \$EDITOR]' \
'--edit[Open created file in \$EDITOR]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':title -- Title for the new document:_default' \
&& ret=0
;;
(retrieve)
_arguments "${_arguments_options[@]}" : \
'-d+[Follow block refs down N levels]:DEPTH:_default' \
'--depth=[Follow block refs down N levels]:DEPTH:_default' \
'-c+[Include N levels of parent context]:CONTEXT:_default' \
'--context=[Include N levels of parent context]:CONTEXT:_default' \
'*-e+[Exclude document key(s) from results (can be specified multiple times)]:EXCLUDE:_default' \
'*--exclude=[Exclude document key(s) from results (can be specified multiple times)]:EXCLUDE:_default' \
'-f+[]:FORMAT:(markdown keys json yaml)' \
'--format=[]:FORMAT:(markdown keys json yaml)' \
'--filter=[Filter expression. Inline YAML; wrapped in \`{}\` and parsed as a filter document. Example\: --filter '\''status\: pending'\''.]:FILTER:_default' \
'*-k+[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--key=[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--includes=[\$includes anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDES:_default' \
'*--included-by=[\$includedBy anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDED_BY:_default' \
'*--references=[\$references anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCES:_default' \
'*--referenced-by=[\$referencedBy anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCED_BY:_default' \
'*--in=[]:IN:_default' \
'*--in-any=[]:IN_ANY:_default' \
'*--not-in=[]:NOT_IN:_default' \
'--refs-to=[]:REFS_TO:_default' \
'--refs-from=[]:REFS_FROM:_default' \
'--max-depth=[Default maxDepth applied to inclusion anchor flags without a colon-suffix. Default 1.]:MAX_DEPTH:_default' \
'--max-distance=[Default maxDistance applied to reference anchor flags without a colon-suffix. Default 1.]:MAX_DISTANCE:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-l[Include inline references]' \
'--links[Include inline references]' \
'-b[Include incoming references]' \
'--backlinks[Include incoming references]' \
'--dry-run[Show document count and total lines without content]' \
'--no-content[Exclude document content from results (metadata only)]' \
'--children[Populate the \`includes\` array with child document edges]' \
'--roots[Only match root documents (those with no incoming inclusion edges).]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(find)
_arguments "${_arguments_options[@]}" : \
'-l+[Maximum results (0 = unlimited)]:LIMIT:_default' \
'--limit=[Maximum results (0 = unlimited)]:LIMIT:_default' \
'--project=[Projection\: comma-list (name, name=path, name=\$selector, \$selector) or inline YAML mapping. Replaces the default.]:PROJECT:_default' \
'(--project)--add-fields=[Additive projection\: same grammar as --project, extends defaults rather than replacing.]:ADD_FIELDS:_default' \
'--sort=[Sort by frontmatter field. Format\: field\:1 (asc) or field\:-1 (desc).]:SORT:_default' \
'-f+[]:FORMAT:(markdown keys json yaml)' \
'--format=[]:FORMAT:(markdown keys json yaml)' \
'--filter=[Filter expression. Inline YAML; wrapped in \`{}\` and parsed as a filter document. Example\: --filter '\''status\: pending'\''.]:FILTER:_default' \
'*-k+[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--key=[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--includes=[\$includes anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDES:_default' \
'*--included-by=[\$includedBy anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDED_BY:_default' \
'*--references=[\$references anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCES:_default' \
'*--referenced-by=[\$referencedBy anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCED_BY:_default' \
'*--in=[]:IN:_default' \
'*--in-any=[]:IN_ANY:_default' \
'*--not-in=[]:NOT_IN:_default' \
'--refs-to=[]:REFS_TO:_default' \
'--refs-from=[]:REFS_FROM:_default' \
'--max-depth=[Default maxDepth applied to inclusion anchor flags without a colon-suffix. Default 1.]:MAX_DEPTH:_default' \
'--max-distance=[Default maxDistance applied to reference anchor flags without a colon-suffix. Default 1.]:MAX_DISTANCE:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--roots[Only match root documents (those with no incoming inclusion edges).]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::query -- Search query (fuzzy match on title and key):_default' \
&& ret=0
;;
(count)
_arguments "${_arguments_options[@]}" : \
'-l+[Cap the number of matches counted (0 = unlimited)]:LIMIT:_default' \
'--limit=[Cap the number of matches counted (0 = unlimited)]:LIMIT:_default' \
'--filter=[Filter expression. Inline YAML; wrapped in \`{}\` and parsed as a filter document. Example\: --filter '\''status\: pending'\''.]:FILTER:_default' \
'*-k+[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--key=[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--includes=[\$includes anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDES:_default' \
'*--included-by=[\$includedBy anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDED_BY:_default' \
'*--references=[\$references anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCES:_default' \
'*--referenced-by=[\$referencedBy anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCED_BY:_default' \
'*--in=[]:IN:_default' \
'*--in-any=[]:IN_ANY:_default' \
'*--not-in=[]:NOT_IN:_default' \
'--refs-to=[]:REFS_TO:_default' \
'--refs-from=[]:REFS_FROM:_default' \
'--max-depth=[Default maxDepth applied to inclusion anchor flags without a colon-suffix. Default 1.]:MAX_DEPTH:_default' \
'--max-distance=[Default maxDistance applied to reference anchor flags without a colon-suffix. Default 1.]:MAX_DISTANCE:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--roots[Only match root documents (those with no incoming inclusion edges).]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(normalize)
_arguments "${_arguments_options[@]}" : \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(tree)
_arguments "${_arguments_options[@]}" : \
'-f+[Output format\: markdown (nested list with links), keys, json, yaml]:FORMAT:(markdown keys json yaml)' \
'--format=[Output format\: markdown (nested list with links), keys, json, yaml]:FORMAT:(markdown keys json yaml)' \
'-d+[Maximum depth to traverse]:DEPTH:_default' \
'--depth=[Maximum depth to traverse]:DEPTH:_default' \
'--project=[Projection\: comma-list (name, name=path, name=\$selector, \$selector) or inline YAML mapping. Replaces user-frontmatter additions.]:PROJECT:_default' \
'(--project)--add-fields=[Additive projection\: extends each tree node'\''s default fields. Same grammar as --project.]:ADD_FIELDS:_default' \
'--filter=[Filter expression. Inline YAML; wrapped in \`{}\` and parsed as a filter document. Example\: --filter '\''status\: pending'\''.]:FILTER:_default' \
'*-k+[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--key=[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--includes=[\$includes anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDES:_default' \
'*--included-by=[\$includedBy anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDED_BY:_default' \
'*--references=[\$references anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCES:_default' \
'*--referenced-by=[\$referencedBy anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCED_BY:_default' \
'*--in=[]:IN:_default' \
'*--in-any=[]:IN_ANY:_default' \
'*--not-in=[]:NOT_IN:_default' \
'--refs-to=[]:REFS_TO:_default' \
'--refs-from=[]:REFS_FROM:_default' \
'--max-depth=[Default maxDepth applied to inclusion anchor flags without a colon-suffix. Default 1.]:MAX_DEPTH:_default' \
'--max-distance=[Default maxDistance applied to reference anchor flags without a colon-suffix. Default 1.]:MAX_DISTANCE:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--roots[Only match root documents (those with no incoming inclusion edges).]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(squash)
_arguments "${_arguments_options[@]}" : \
'-d+[]:DEPTH:_default' \
'--depth=[]:DEPTH:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':key -- Document key to squash:_default' \
&& ret=0
;;
(export)
_arguments "${_arguments_options[@]}" : \
'-f+[Output format]:FORMAT:(dot)' \
'--format=[Output format]:FORMAT:(dot)' \
'-d+[]:DEPTH:_default' \
'--depth=[]:DEPTH:_default' \
'--filter=[Filter expression. Inline YAML; wrapped in \`{}\` and parsed as a filter document. Example\: --filter '\''status\: pending'\''.]:FILTER:_default' \
'*-k+[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--key=[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--includes=[\$includes anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDES:_default' \
'*--included-by=[\$includedBy anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDED_BY:_default' \
'*--references=[\$references anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCES:_default' \
'*--referenced-by=[\$referencedBy anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCED_BY:_default' \
'*--in=[]:IN:_default' \
'*--in-any=[]:IN_ANY:_default' \
'*--not-in=[]:NOT_IN:_default' \
'--refs-to=[]:REFS_TO:_default' \
'--refs-from=[]:REFS_FROM:_default' \
'--max-depth=[Default maxDepth applied to inclusion anchor flags without a colon-suffix. Default 1.]:MAX_DEPTH:_default' \
'--max-distance=[Default maxDistance applied to reference anchor flags without a colon-suffix. Default 1.]:MAX_DISTANCE:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--include-headers[Include section headers and create subgraphs for detailed visualization. When enabled, shows document structure with sections grouped in colored subgraphs]' \
'--roots[Only match root documents (those with no incoming inclusion edges).]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(schema)
_arguments "${_arguments_options[@]}" : \
'-f+[Output format for schema]:FORMAT:(markdown json yaml)' \
'--format=[Output format for schema]:FORMAT:(markdown json yaml)' \
'--field=[Restrict output to a specific field (and its children)]:FIELD:_default' \
'--filter=[Filter expression. Inline YAML; wrapped in \`{}\` and parsed as a filter document. Example\: --filter '\''status\: pending'\''.]:FILTER:_default' \
'*-k+[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--key=[Match by document key. Repeatable\: 1 key uses \$eq, 2+ uses \$in.]:KEY:_default' \
'*--includes=[\$includes anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDES:_default' \
'*--included-by=[\$includedBy anchor. KEY or KEY\:DEPTH (DEPTH defaults to --max-depth). Lowers to scalar shorthand when DEPTH=1, full form { match\: { \$key\: KEY }, maxDepth\: N } otherwise. Repeatable; anchors are ANDed.]:INCLUDED_BY:_default' \
'*--references=[\$references anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCES:_default' \
'*--referenced-by=[\$referencedBy anchor. KEY or KEY\:DIST (DIST defaults to --max-distance). Lowers to scalar shorthand when DIST=1, full form { match\: { \$key\: KEY }, maxDistance\: N } otherwise. Repeatable; anchors are ANDed.]:REFERENCED_BY:_default' \
'*--in=[]:IN:_default' \
'*--in-any=[]:IN_ANY:_default' \
'*--not-in=[]:NOT_IN:_default' \
'--refs-to=[]:REFS_TO:_default' \
'--refs-from=[]:REFS_FROM:_default' \
'--max-depth=[Default maxDepth applied to inclusion anchor flags without a colon-suffix. Default 1.]:MAX_DEPTH:_default' \
'--max-distance=[Default maxDistance applied to reference anchor flags without a colon-suffix. Default 1.]:MAX_DISTANCE:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--roots[Only match root documents (those with no incoming inclusion edges).]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(stats)
_arguments "${_arguments_options[@]}" : \
'-f+[Output format for statistics]:FORMAT:(markdown csv json yaml)' \
'--format=[Output format for statistics]:FORMAT:(markdown csv json yaml)' \
'-k+[Document key for per-document stats. Omit for aggregate graph statistics.]:KEY:_default' \
'--key=[Document key for per-document stats. Omit for aggregate graph statistics.]:KEY:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(rename)
_arguments "${_arguments_options[@]}" : \
'-f+[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'--format=[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--dry-run[Preview changes without writing to disk]' \
'--quiet[Suppress progress output]' \
'--keys[]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':old_key -- Current document key:_default' \
':new_key -- New document key:_default' \
&& ret=0
;;
(delete)
_arguments "${_arguments_options[@]}" : \
'--filter=[Filter expression (inline YAML). Required if positional KEY omitted.]:FILTER:_default' \
'-f+[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'--format=[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--dry-run[Preview changes without writing to disk]' \
'--quiet[Suppress progress output]' \
'--keys[]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::key -- Document key to delete (sugar for --filter '\''$key\: K'\''):_default' \
&& ret=0
;;
(extract)
_arguments "${_arguments_options[@]}" : \
'(--block)--section=[Section title to extract (case-insensitive)]:SECTION:_default' \
'(--section)--block=[Block number to extract (1-indexed)]:BLOCK:_default' \
'--action=[Action name from config to use for extraction]:ACTION:_default' \
'-f+[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'--format=[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--list[List all sections with block numbers]' \
'--dry-run[Preview changes without writing to disk]' \
'--quiet[Suppress progress output]' \
'--keys[]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':key -- Document key containing the section to extract:_default' \
&& ret=0
;;
(inline)
_arguments "${_arguments_options[@]}" : \
'--reference=[Reference key or title to inline]:REFERENCE:_default' \
'--block=[Block number to inline (1-indexed)]:BLOCK:_default' \
'--action=[Action name from config to use for inlining]:ACTION:_default' \
'-f+[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'--format=[Output format. \`keys\` prints affected document keys (one per line) and suppresses progress.]:FORMAT:(markdown keys)' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--list[List all block references with numbers]' \
'--as-quote[Inline as blockquote instead of section]' \
'--keep-target[Keep the target document after inlining]' \
'--dry-run[Preview changes without writing to disk]' \
'--quiet[Suppress progress output]' \
'--keys[]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':key -- Document key containing the reference to inline:_default' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
'-k+[Document key. Required for body-overwrite mode; optional in frontmatter mutation mode.]:KEY:_default' \
'--key=[Document key. Required for body-overwrite mode; optional in frontmatter mutation mode.]:KEY:_default' \
'-c+[New full markdown content (body-overwrite mode). Use '\''-'\'' to read from stdin.]:CONTENT:_default' \
'--content=[New full markdown content (body-overwrite mode). Use '\''-'\'' to read from stdin.]:CONTENT:_default' \
'--filter=[Filter expression for frontmatter mutation mode (inline YAML). Combined with -k via AND.]:FILTER:_default' \
'*--set=[Frontmatter \$set assignment FIELD=VALUE. VALUE is parsed as a YAML scalar.]:SET:_default' \
'*--unset=[Frontmatter \$unset field name.]:UNSET:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--dry-run[Preview without writing]' \
'--quiet[Suppress progress output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(attach)
_arguments "${_arguments_options[@]}" : \
'*--to=[Configured attach action(s) to attach to. Repeatable for multiple targets.]:TO:_default' \
'-k+[Source document key to attach]:KEY:_default' \
'--key=[Source document key to attach]:KEY:_default' \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'--list[List configured attach actions]' \
'--dry-run[Preview without writing]' \
'--quiet[Suppress progress output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-v+[]:VERBOSE:_default' \
'--verbose=[]:VERBOSE:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':shell -- Target shell:(bash elvish fish nushell powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_iwe__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:iwe-help-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(retrieve)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(find)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(count)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(normalize)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(tree)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(squash)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(export)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(schema)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(stats)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(rename)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(delete)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(extract)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(inline)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(attach)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_iwe_commands] )) ||
_iwe_commands() {
    local commands; commands=(
'init:Initialize the current directory as an IWE project' \
'new:Create a new document from a template' \
'retrieve:Retrieve document content with expansion and context' \
'find:Search and discover documents' \
'count:Count documents matching a filter ' \
'normalize:Normalize all markdown files in the project' \
'tree:Display document hierarchy as a tree' \
'squash:Consolidate linked documents into a single file' \
'export:Export the graph structure in various formats' \
'schema:Infer and display frontmatter schema' \
'stats:Display graph statistics' \
'rename:Rename a document and update all references to it' \
'delete:Delete a document and clean up all references to it' \
'extract:Extract a section to a new document with an inclusion link' \
'inline:Replace an inclusion link with the referenced document content' \
'update:Update document content or frontmatter' \
'attach:Attach a document as a block reference via configured attach actions' \
'completions:Generate shell completion script' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'iwe commands' commands "$@"
}
(( $+functions[_iwe__subcmd__attach_commands] )) ||
_iwe__subcmd__attach_commands() {
    local commands; commands=()
    _describe -t commands 'iwe attach commands' commands "$@"
}
(( $+functions[_iwe__subcmd__completions_commands] )) ||
_iwe__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'iwe completions commands' commands "$@"
}
(( $+functions[_iwe__subcmd__count_commands] )) ||
_iwe__subcmd__count_commands() {
    local commands; commands=()
    _describe -t commands 'iwe count commands' commands "$@"
}
(( $+functions[_iwe__subcmd__delete_commands] )) ||
_iwe__subcmd__delete_commands() {
    local commands; commands=()
    _describe -t commands 'iwe delete commands' commands "$@"
}
(( $+functions[_iwe__subcmd__export_commands] )) ||
_iwe__subcmd__export_commands() {
    local commands; commands=()
    _describe -t commands 'iwe export commands' commands "$@"
}
(( $+functions[_iwe__subcmd__extract_commands] )) ||
_iwe__subcmd__extract_commands() {
    local commands; commands=()
    _describe -t commands 'iwe extract commands' commands "$@"
}
(( $+functions[_iwe__subcmd__find_commands] )) ||
_iwe__subcmd__find_commands() {
    local commands; commands=()
    _describe -t commands 'iwe find commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help_commands] )) ||
_iwe__subcmd__help_commands() {
    local commands; commands=(
'init:Initialize the current directory as an IWE project' \
'new:Create a new document from a template' \
'retrieve:Retrieve document content with expansion and context' \
'find:Search and discover documents' \
'count:Count documents matching a filter ' \
'normalize:Normalize all markdown files in the project' \
'tree:Display document hierarchy as a tree' \
'squash:Consolidate linked documents into a single file' \
'export:Export the graph structure in various formats' \
'schema:Infer and display frontmatter schema' \
'stats:Display graph statistics' \
'rename:Rename a document and update all references to it' \
'delete:Delete a document and clean up all references to it' \
'extract:Extract a section to a new document with an inclusion link' \
'inline:Replace an inclusion link with the referenced document content' \
'update:Update document content or frontmatter' \
'attach:Attach a document as a block reference via configured attach actions' \
'completions:Generate shell completion script' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'iwe help commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__attach_commands] )) ||
_iwe__subcmd__help__subcmd__attach_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help attach commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__completions_commands] )) ||
_iwe__subcmd__help__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help completions commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__count_commands] )) ||
_iwe__subcmd__help__subcmd__count_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help count commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__delete_commands] )) ||
_iwe__subcmd__help__subcmd__delete_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help delete commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__export_commands] )) ||
_iwe__subcmd__help__subcmd__export_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help export commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__extract_commands] )) ||
_iwe__subcmd__help__subcmd__extract_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help extract commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__find_commands] )) ||
_iwe__subcmd__help__subcmd__find_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help find commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__help_commands] )) ||
_iwe__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help help commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__init_commands] )) ||
_iwe__subcmd__help__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help init commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__inline_commands] )) ||
_iwe__subcmd__help__subcmd__inline_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help inline commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__new_commands] )) ||
_iwe__subcmd__help__subcmd__new_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help new commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__normalize_commands] )) ||
_iwe__subcmd__help__subcmd__normalize_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help normalize commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__rename_commands] )) ||
_iwe__subcmd__help__subcmd__rename_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help rename commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__retrieve_commands] )) ||
_iwe__subcmd__help__subcmd__retrieve_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help retrieve commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__schema_commands] )) ||
_iwe__subcmd__help__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help schema commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__squash_commands] )) ||
_iwe__subcmd__help__subcmd__squash_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help squash commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__stats_commands] )) ||
_iwe__subcmd__help__subcmd__stats_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help stats commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__tree_commands] )) ||
_iwe__subcmd__help__subcmd__tree_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help tree commands' commands "$@"
}
(( $+functions[_iwe__subcmd__help__subcmd__update_commands] )) ||
_iwe__subcmd__help__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'iwe help update commands' commands "$@"
}
(( $+functions[_iwe__subcmd__init_commands] )) ||
_iwe__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'iwe init commands' commands "$@"
}
(( $+functions[_iwe__subcmd__inline_commands] )) ||
_iwe__subcmd__inline_commands() {
    local commands; commands=()
    _describe -t commands 'iwe inline commands' commands "$@"
}
(( $+functions[_iwe__subcmd__new_commands] )) ||
_iwe__subcmd__new_commands() {
    local commands; commands=()
    _describe -t commands 'iwe new commands' commands "$@"
}
(( $+functions[_iwe__subcmd__normalize_commands] )) ||
_iwe__subcmd__normalize_commands() {
    local commands; commands=()
    _describe -t commands 'iwe normalize commands' commands "$@"
}
(( $+functions[_iwe__subcmd__rename_commands] )) ||
_iwe__subcmd__rename_commands() {
    local commands; commands=()
    _describe -t commands 'iwe rename commands' commands "$@"
}
(( $+functions[_iwe__subcmd__retrieve_commands] )) ||
_iwe__subcmd__retrieve_commands() {
    local commands; commands=()
    _describe -t commands 'iwe retrieve commands' commands "$@"
}
(( $+functions[_iwe__subcmd__schema_commands] )) ||
_iwe__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'iwe schema commands' commands "$@"
}
(( $+functions[_iwe__subcmd__squash_commands] )) ||
_iwe__subcmd__squash_commands() {
    local commands; commands=()
    _describe -t commands 'iwe squash commands' commands "$@"
}
(( $+functions[_iwe__subcmd__stats_commands] )) ||
_iwe__subcmd__stats_commands() {
    local commands; commands=()
    _describe -t commands 'iwe stats commands' commands "$@"
}
(( $+functions[_iwe__subcmd__tree_commands] )) ||
_iwe__subcmd__tree_commands() {
    local commands; commands=()
    _describe -t commands 'iwe tree commands' commands "$@"
}
(( $+functions[_iwe__subcmd__update_commands] )) ||
_iwe__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'iwe update commands' commands "$@"
}

if [ "$funcstack[1]" = "_iwe" ]; then
    _iwe "$@"
else
    compdef _iwe iwe
fi
