#compdef nucleos

autoload -U is-at-least

_nucleos() {
    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[@]}" : \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'--output=[Report format, given BEFORE the subcommand]:OUTPUT:(text json)' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'--license[Print the full proprietary licence text and exit]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_nucleos_commands" \
"*::: :->nucleos" \
&& ret=0
    case $state in
    (nucleos)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:nucleos-command-$line[1]:"
        case $line[1] in
            (anonymize)
_arguments "${_arguments_options[@]}" : \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help]' \
'--help[Print help]' \
':model_path -- Path to the `.dzn` source file to anonymize. Use `-` to read from stdin (matches the convention of `parse -E`'\''s output → pipeline use):_default' \
&& ret=0
;;
(bug-report)
_arguments "${_arguments_options[@]}" : \
'-o+[Output path; extension picks format (.zip / .tar.gz / .tgz / .tar)]:FILE:_files' \
'--out=[Output path; extension picks format (.zip / .tar.gz / .tgz / .tar)]:FILE:_files' \
'--model=[Include this .dzn file (flattened via \`parse -E\`)]:DZN:_files' \
'*-I+[Import directory for --model (repeatable)]:DIR:_files' \
'*--import=[Import directory for --model (repeatable)]:DIR:_files' \
'--panic-log=[Include this captured panic stderr (overrides last-panic.log auto-pickup)]:FILE:_files' \
'--capture-output=[Include this captured run output (overrides last-run.log auto-pickup)]:FILE:_files' \
'--description=[Free-text "what went wrong" note]:TEXT:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'(--no-anonymize)--anonymize[Force-anonymize the model (skips the anonymize prompt)]' \
'(--anonymize)--no-anonymize[Force-DO-NOT-anonymize the model (skips the anonymize prompt)]' \
'--no-last-panic[Skip auto-pickup of last-panic.log]' \
'--no-last-run[Skip auto-pickup of last-run.log]' \
'--no-infer[Skip argv inference from last-{panic,run}.log]' \
'--no-env[Skip env-var collection (privacy override)]' \
'-y[Non-interactive\: skip all prompts, take each default]' \
'--yes[Non-interactive\: skip all prompts, take each default]' \
'(--model)--include-source[Force "yes" to the source-inclusion prompt]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(parse)
_arguments "${_arguments_options[@]}" : \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-E[Resolve imports and write the flattened source to stdout (gcc-style preprocessor mode)]' \
'--preprocess[Resolve imports and write the flattened source to stdout (gcc-style preprocessor mode)]' \
'-D[With \`-E\`\: omit the \`#file\`/\`#imported\` directive lines]' \
'--no-directives[With \`-E\`\: omit the \`#file\`/\`#imported\` directive lines]' \
'-l[Print \`<name> <type>\` for each model declared in FILE, then exit]' \
'--list-models[Print \`<name> <type>\` for each model declared in FILE, then exit]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(inspect-ports)
_arguments "${_arguments_options[@]}" : \
'-m+[Restrict introspection to model MODEL]:MODEL:_default' \
'--model=[Restrict introspection to model MODEL]:MODEL:_default' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(lts)
_arguments "${_arguments_options[@]}" : \
'-m+[Select component/interface by name]:MODEL:_default' \
'--model=[Select component/interface by name]:MODEL:_default' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'-q+[Event queue size \[3\]]:N:_default' \
'--queue-size=[Event queue size \[3\]]:N:_default' \
'--queue-size-defer=[Defer queue size \[2\]]:N:_default' \
'--queue-size-external=[External queue size \[1\]]:N:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'--full-lts[Emit the full LTS instead of the fail-fast one]' \
'--defer-origin[Tag each \`<defer>\` discharge edge with its origin leaf]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help]' \
'--help[Print help]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(traces)
_arguments "${_arguments_options[@]}" : \
'-m+[Select component/interface by name]:MODEL:_default' \
'--model=[Select component/interface by name]:MODEL:_default' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'-o+[Write traces to DIR as \`<model>.trace.<N>\` (default "."); \`-\` writes all traces to stdout]:DIR:_default' \
'--output=[Write traces to DIR as \`<model>.trace.<N>\` (default "."); \`-\` writes all traces to stdout]:DIR:_default' \
'-q+[Event queue size \[3\]]:N:_default' \
'--queue-size=[Event queue size \[3\]]:N:_default' \
'--queue-size-defer=[Defer queue size \[2\]]:N:_default' \
'--queue-size-external=[External queue size \[1\]]:N:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-f[Include \`<flush>\` events in the traces]' \
'--flush[Include \`<flush>\` events in the traces]' \
'-i[Include traces that lead to an illegal]' \
'--illegal[Include traces that lead to an illegal]' \
'--defer-origin[Tag each \`<defer>\` discharge edge with its origin leaf]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(lts-walk)
_arguments "${_arguments_options[@]}" : \
'-m+[Select component/interface by name]:MODEL:_default' \
'--model=[Select component/interface by name]:MODEL:_default' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'-t+[Read trace from FILE (default\: stdin)]:FILE:_default' \
'--trail=[Read trace from FILE (default\: stdin)]:FILE:_default' \
'-q+[Event queue size]:N:_default' \
'--queue-size=[Event queue size]:N:_default' \
'--queue-size-defer=[Defer queue size]:N:_default' \
'--queue-size-external=[External queue size]:N:_default' \
'--compare-aut=[Diff weak-refusal sets against a second LTS read from FILE]:FILE:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'--show-eligible[Print weak-outgoing label set at each step]' \
'--state-as-tau[Treat \`port.<state>(...)\` labels as tau when stepping]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(lts-diagnose)
_arguments "${_arguments_options[@]}" : \
'-m+[Select component by name]:MODEL:_default' \
'--model=[Select component by name]:MODEL:_default' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'--state=[Post-trigger LTS state id to trace verbosely]:N:_default' \
'-q+[Event queue size]:N:_default' \
'--queue-size=[Event queue size]:N:_default' \
'--queue-size-defer=[Defer queue size]:N:_default' \
'--queue-size-external=[External queue size]:N:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" : \
'-m+[Restrict verification to model MODEL]:MODEL:_default' \
'--model=[Restrict verification to model MODEL]:MODEL:_default' \
'--output=[Report format\: \`text\` (default) or \`json\`]:FORMAT:(text json)' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'-q+[Event queue size \[3\]]:N:_default' \
'--queue-size=[Event queue size \[3\]]:N:_default' \
'--queue-size-defer=[Defer queue size \[2\]]:N:_default' \
'--queue-size-external=[External queue size \[1\]]:N:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-k[Keep verifying after finding an error (default\: stop on first)]' \
'--keep-going[Keep verifying after finding an error (default\: stop on first)]' \
'--no-interfaces[Skip interface verification]' \
'-U[Skip the unreachable code check]' \
'--no-unreachable[Skip the unreachable code check]' \
'--full-lts[Explore the full LTS instead of stopping at the first error edge]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help]' \
'--help[Print help]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(simulate)
_arguments "${_arguments_options[@]}" : \
'-m+[Select component/interface by name]:MODEL:_default' \
'--model=[Select component/interface by name]:MODEL:_default' \
'--output=[Report format\: \`text\` (default) or \`json\`]:FORMAT:(text json)' \
'*-I+[Add DIR to import path (repeatable)]:DIR:_default' \
'*--import=[Add DIR to import path (repeatable)]:DIR:_default' \
'-t+[Read trace from FILE (default\: stdin)]:FILE:_default' \
'--trail=[Read trace from FILE (default\: stdin)]:FILE:_default' \
'-q+[Event queue size \[3\]]:N:_default' \
'--queue-size=[Event queue size \[3\]]:N:_default' \
'--queue-size-defer=[Defer queue size \[2\]]:N:_default' \
'--queue-size-external=[External queue size \[1\]]:N:_default' \
'--check-trace=[Test the REPL against a golden trace FILE. Implies \`--repl\`]:FILE:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'--repl[REPL mode\: drive the model interactively, one event per line on stdin]' \
'--defer-any-order[Follow the trace'\''s defer discharge order, not a global defer FIFO]' \
'--defer-origin[Tag each \`<defer>\` discharge edge with its origin leaf]' \
'-f[Accept \`p.<flush>\` queue-drain tokens in a fed trace]' \
'--flush[Accept \`p.<flush>\` queue-drain tokens in a fed trace]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help]' \
'--help[Print help]' \
':model_path -- Path to the .dzn model file:_default' \
&& ret=0
;;
(trace)
_arguments "${_arguments_options[@]}" : \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::file -- Trace input FILE (default\: stdin):_default' \
&& ret=0
;;
(code)
_arguments "${_arguments_options[@]}" : \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::args -- Arguments passed straight through to `dzn`:_default' \
&& ret=0
;;
(graph)
_arguments "${_arguments_options[@]}" : \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::args -- Arguments passed straight through to `dzn`:_default' \
&& ret=0
;;
(sim-judge)
_arguments "${_arguments_options[@]}" : \
'--class=[Classification\: shape (default) | exact | goldenartifact | nondet | stateartifact]:CLASS:_default' \
'--threads=[Parallel BFS threads \[1\]]:N:_default' \
'--emit-doc[Emit the normative doc sections (§6/§7/§8) from the code]' \
'-v[Report progress while working, not just the result]' \
'--verbose[Report progress while working, not just the result]' \
'*-d[Enable debug output and a full diagnostic backtrace on panic]' \
'*--debug[Enable debug output and a full diagnostic backtrace on panic]' \
'-p[Skip well-formedness checking]' \
'--skip-wfc[Skip well-formedness checking]' \
'--no-compress[Disable leaf-LTS compression when composing a system LTS]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::golden -- Reference (golden) output file:_default' \
'::ours -- Our output file to judge:_default' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_nucleos_commands] )) ||
_nucleos_commands() {
    local commands; commands=(
'anonymize:Rewrite a .dzn source file with identifiers replaced by \`_<N>\` and comments stripped' \
'bug-report:Bundle diagnostic info into a .zip / .tar.gz archive for a support ticket' \
'parse:Parse a Dezyne file and run well-formedness checks' \
'inspect-ports:(dev) Emit JSON describing the ports of a component or interface' \
'lts:Generate an LTS for a Dezyne component or interface in \`.aut\` format' \
'traces:Generate an exhaustive set of traces for a Dezyne model' \
'lts-walk:(dev) Replay a trace through the generated LTS, dumping state vectors at each step' \
'lts-diagnose:(dev) Stream a verbose \`\[dbg\]\` trace of one handler'\''s LTS exploration' \
'verify:Check a Dezyne model for verification errors (deadlock, livelock, illegal, ...)' \
'simulate:Simulate a Dezyne model against a trace' \
'trace:(dev) Convert \`simulate\` text output to sequence-diagram JSON' \
'code:Generate code for a Dezyne model — FORWARDED to the legacy \`dzn\`' \
'graph:Graph a Dezyne model — system view / state diagram — FORWARDED to \`dzn\`' \
'sim-judge:(dev) Judge a simulate/repl output against a golden' \
    )
    _describe -t commands 'nucleos commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__anonymize_commands] )) ||
_nucleos__subcmd__anonymize_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos anonymize commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__bug-report_commands] )) ||
_nucleos__subcmd__bug-report_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos bug-report commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__code_commands] )) ||
_nucleos__subcmd__code_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos code commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__graph_commands] )) ||
_nucleos__subcmd__graph_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos graph commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__inspect-ports_commands] )) ||
_nucleos__subcmd__inspect-ports_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos inspect-ports commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__lts_commands] )) ||
_nucleos__subcmd__lts_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos lts commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__lts-diagnose_commands] )) ||
_nucleos__subcmd__lts-diagnose_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos lts-diagnose commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__lts-walk_commands] )) ||
_nucleos__subcmd__lts-walk_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos lts-walk commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__parse_commands] )) ||
_nucleos__subcmd__parse_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos parse commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__sim-judge_commands] )) ||
_nucleos__subcmd__sim-judge_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos sim-judge commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__simulate_commands] )) ||
_nucleos__subcmd__simulate_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos simulate commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__trace_commands] )) ||
_nucleos__subcmd__trace_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos trace commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__traces_commands] )) ||
_nucleos__subcmd__traces_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos traces commands' commands "$@"
}
(( $+functions[_nucleos__subcmd__verify_commands] )) ||
_nucleos__subcmd__verify_commands() {
    local commands; commands=()
    _describe -t commands 'nucleos verify commands' commands "$@"
}

if [ "$funcstack[1]" = "_nucleos" ]; then
    _nucleos "$@"
else
    compdef _nucleos nucleos
fi
