#compdef arf

autoload -U is-at-least

_arf() {
    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[@]}" : \
'-e+[Evaluate R expression and exit]:EVAL:_default' \
'--eval=[Evaluate R expression and exit]:EVAL:_default' \
'(-e --eval)-f+[\[R\] Take input from FILE]:FILE:_files' \
'(-e --eval)--file=[\[R\] Take input from FILE]:FILE:_files' \
'-c+[Path to configuration file]:CONFIG:_files' \
'--config=[Path to configuration file]:CONFIG:_files' \
'(--r-home)--with-r-version=[R version to use via rig (overrides r_source config)]:R_VERSION:_default' \
'(--with-r-version)--r-home=[Explicit R_HOME path (overrides r_source config)]:R_HOME:_files -/' \
'--encoding=[\[R\] Specify encoding to be used for stdin (no-op)]:ENCODING:_default' \
'--max-connections=[\[R\] Set max number of connections to N]:MAX_CONNECTIONS:_default' \
'--max-ppsize=[\[R\] Set max size of protect stack to N]:MAX_PPSIZE:_default' \
'--min-nsize=[\[R\] Set min number of fixed size obj'\''s ("cons cells") to N]:MIN_NSIZE:_default' \
'--min-vsize=[\[R\] Set vector heap minimum to N bytes; '\''4M'\'' = 4 MegaB]:MIN_VSIZE:_default' \
'-d+[\[R\] Run R through debugger NAME (no-op)]:DEBUGGER:_default' \
'--debugger=[\[R\] Run R through debugger NAME (no-op)]:DEBUGGER:_default' \
'--debugger-args=[\[R\] Pass ARGS as arguments to the debugger (no-op)]:DEBUGGER_ARGS:_default' \
'-g+[\[R\] Use TYPE as GUI (no-op)]:GUI:_default' \
'--gui=[\[R\] Use TYPE as GUI (no-op)]:GUI:_default' \
'--arch=[\[R\] Specify a sub-architecture (no-op)]:ARCH:_default' \
'--ipc-bind=[Bind IPC socket to a specific path instead of the default (requires --with-ipc)]:IPC_BIND:_files' \
'--ipc-pid-file=[Write server PID to a file on startup (requires --with-ipc)]:IPC_PID_FILE:_files' \
'--history-dir=[Custom history directory (overrides default XDG location)]:HISTORY_DIR:_files -/' \
'--reprex[Enable reprex mode (no prompt, output prefixed with #>)]' \
'--auto-format[Enable auto-formatting of R code in reprex mode (requires Air CLI)]' \
'--no-banner[Suppress the startup banner]' \
'--vanilla[Start R in vanilla mode (no init files, no save/restore)]' \
'-q[\[R\] Don'\''t print R startup message]' \
'--quiet[\[R\] Don'\''t print R startup message]' \
'--no-save[\[R\] Don'\''t save workspace at end of session (default)]' \
'(--no-save)--save[\[R\] Save workspace at end of session]' \
'--no-restore[\[R\] Don'\''t restore previously saved objects (default)]' \
'--no-restore-data[\[R\] Don'\''t restore previously saved objects]' \
'(--no-restore --no-restore-data)--restore-data[\[R\] Restore previously saved objects]' \
'--no-environ[\[R\] Don'\''t read the site and user environment files]' \
'--no-site-file[\[R\] Don'\''t read the site-wide Rprofile]' \
'--no-init-file[\[R\] Don'\''t read the user'\''s .Rprofile]' \
'--interactive[\[R\] Force R to run interactively (no-op, always interactive)]' \
'--no-echo[\[R\] Don'\''t echo input (no-op, arf controls its own echo)]' \
'--slave[\[R\] Combine --quiet --no-save --no-restore (deprecated in R 4.0, use --no-echo)]' \
'(--no-restore --no-restore-data)--restore[\[R\] Restore previously saved objects (opposite of --no-restore)]' \
'--verbose[\[R\] Print more information about progress (no-op)]' \
'--args[\[R\] In R, skip the rest of the command line. arf accepts this flag for compatibility but does NOT consume trailing arguments; unknown flags after --args will still cause a parse error]' \
'--no-readline[\[R\] Don'\''t use readline (no-op)]' \
'--no-restore-history[\[R\] Don'\''t restore history (no-op)]' \
'--with-ipc[Enable IPC server for external tool access (AI agents, vscode-R, etc.)]' \
'--no-auto-match[Disable auto-matching of brackets and quotes (for testing)]' \
'--no-completion[Disable completion menu (for testing)]' \
'--no-history[Disable history (no history saved or loaded)]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_arf_commands" \
"*::: :->arf" \
&& ret=0
    case $state in
    (arf)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-command-$line[1]:"
        case $line[1] in
            (completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell -- The shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_arf__subcmd__config_commands" \
"*::: :->config" \
&& ret=0

    case $state in
    (config)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-config-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
'-f[Overwrite existing configuration file]' \
'--force[Overwrite existing configuration file]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to configuration file to check (defaults to XDG config location)]:CONFIG:_files' \
'--config=[Path to configuration file to check (defaults to XDG config location)]:CONFIG:_files' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__config__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-config-help-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(history)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_arf__subcmd__history_commands" \
"*::: :->history" \
&& ret=0

    case $state in
    (history)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-history-command-$line[1]:"
        case $line[1] in
            (schema)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(import)
_arguments "${_arguments_options[@]}" : \
'--from=[Source format to import from]:FROM:((radian\:"radian history file (~/.radian_history)"
r\:"R native history file (.Rhistory)"
arf\:"Another arf SQLite history database"))' \
'--file=[Path to the history file/database to import. Defaults\: radian=~/.radian_history, r=.Rhistory, arf=history.dir/r.db]:FILE:_files' \
'--hostname=[Override hostname for imported entries. Marks entries to distinguish them from native arf history]:HOSTNAME:_default' \
'--r-table=[Table name for R history when importing from unified export file]:R_TABLE:_default' \
'--shell-table=[Table name for shell history when importing from unified export file]:SHELL_TABLE:_default' \
'--dry-run[Perform a dry run without actually importing]' \
'--import-duplicates[Import duplicate entries instead of skipping them. By default, entries that already exist in the target database are skipped (anti-join on command text and timestamp)]' \
'--unified[Force unified export file mode (imports both R and shell history)]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(export)
_arguments "${_arguments_options[@]}" : \
'--file=[Path to the output SQLite file]:FILE:_files' \
'--r-table=[Table name for R history in the output file]:R_TABLE:_default' \
'--shell-table=[Table name for shell history in the output file]:SHELL_TABLE:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__history__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-history-help-command-$line[1]:"
        case $line[1] in
            (schema)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(import)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(export)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(ipc)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
":: :_arf__subcmd__ipc_commands" \
"*::: :->ipc" \
&& ret=0

    case $state in
    (ipc)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-ipc-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(eval)
_arguments "${_arguments_options[@]}" : \
'--pid=[PID of the target arf session (optional if only one session is running)]:PID:_default' \
'--timeout=[Timeout in milliseconds for waiting for the response (default\: 300000 = 5 minutes). This does NOT cancel the R evaluation — long-running code keeps R busy after timeout]:TIMEOUT:_default' \
'--visible[Also show output in the session (REPL or headless stdout)]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::code -- R code to evaluate (reads from stdin if omitted):_default' \
&& ret=0
;;
(send)
_arguments "${_arguments_options[@]}" : \
'--pid=[PID of the target arf session (optional if only one session is running)]:PID:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::code -- R code to send (reads from stdin if omitted):_default' \
&& ret=0
;;
(session)
_arguments "${_arguments_options[@]}" : \
'--pid=[PID of the target arf session (optional if only one session is running)]:PID:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(shutdown)
_arguments "${_arguments_options[@]}" : \
'--pid=[PID of the target arf session (optional if only one session is running)]:PID:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(history)
_arguments "${_arguments_options[@]}" : \
'--limit=[Maximum number of entries to return (must be positive)]:LIMIT:_default' \
'--cwd=[Filter entries by exact working directory]:CWD:_default' \
'--grep=[Filter entries whose command contains this substring]:GREP:_default' \
'--since=[Only return entries after this timestamp (RFC 3339 or YYYY-MM-DD)]:SINCE:_default' \
'--pid=[PID of the target arf session (optional if only one session is running)]:PID:_default' \
'--all-sessions[Include entries from all sessions, not just the current one]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__ipc__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-ipc-help-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(eval)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(send)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(session)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(shutdown)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(history)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(headless)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to configuration file]:CONFIG:_files' \
'--config=[Path to configuration file]:CONFIG:_files' \
'(--r-home)--with-r-version=[R version to use via rig (overrides r_source config)]:R_VERSION:_default' \
'(--with-r-version)--r-home=[Explicit R_HOME path (overrides r_source config)]:R_HOME:_files -/' \
'--ipc-bind=[Bind IPC socket to a specific path instead of the default. On Unix, ensure the parent directory is user-private (mode 0700) to avoid a brief permission window before the socket is restricted]:BIND:_files' \
'--ipc-pid-file=[Write server PID to a file (removed on shutdown)]:PID_FILE:_files' \
'--log-file=[Redirect log output to a file instead of stderr]:LOG_FILE:_files' \
'--max-connections=[\[R\] Set max number of connections to N]:MAX_CONNECTIONS:_default' \
'--max-ppsize=[\[R\] Set max size of protect stack to N]:MAX_PPSIZE:_default' \
'--history-dir=[Custom history directory (overrides default XDG location)]:HISTORY_DIR:_files -/' \
'--min-nsize=[\[R\] Set min number of fixed size obj'\''s ("cons cells") to N]:MIN_NSIZE:_default' \
'--min-vsize=[\[R\] Set vector heap minimum to N bytes; '\''4M'\'' = 4 MegaB]:MIN_VSIZE:_default' \
'--quiet[Suppress status messages on stderr (IPC path, ready, shutdown)]' \
'--json[Print session info as JSON to stdout when ready]' \
'--vanilla[Start R in vanilla mode (no init files, no save/restore)]' \
'--no-environ[\[R\] Don'\''t read the site and user environment files]' \
'--no-site-file[\[R\] Don'\''t read the site-wide Rprofile]' \
'--no-init-file[\[R\] Don'\''t read the user'\''s .Rprofile]' \
'--no-history[Disable history (no history saved)]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-help-command-$line[1]:"
        case $line[1] in
            (completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__help__subcmd__config_commands" \
"*::: :->config" \
&& ret=0

    case $state in
    (config)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-help-config-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(history)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__help__subcmd__history_commands" \
"*::: :->history" \
&& ret=0

    case $state in
    (history)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-help-history-command-$line[1]:"
        case $line[1] in
            (schema)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(import)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(export)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(ipc)
_arguments "${_arguments_options[@]}" : \
":: :_arf__subcmd__help__subcmd__ipc_commands" \
"*::: :->ipc" \
&& ret=0

    case $state in
    (ipc)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:arf-help-ipc-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(eval)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(send)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(session)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(shutdown)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(history)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(headless)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_arf_commands] )) ||
_arf_commands() {
    local commands; commands=(
'completions:Generate shell completion scripts' \
'config:Configuration management' \
'history:History management' \
'ipc:Interact with a running arf session via IPC' \
'headless:Run R with IPC server only (no interactive REPL)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf commands' commands "$@"
}
(( $+functions[_arf__subcmd__completions_commands] )) ||
_arf__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'arf completions commands' commands "$@"
}
(( $+functions[_arf__subcmd__config_commands] )) ||
_arf__subcmd__config_commands() {
    local commands; commands=(
'init:Generate a default configuration file' \
'check:Validate the configuration file' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf config commands' commands "$@"
}
(( $+functions[_arf__subcmd__config__subcmd__check_commands] )) ||
_arf__subcmd__config__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'arf config check commands' commands "$@"
}
(( $+functions[_arf__subcmd__config__subcmd__help_commands] )) ||
_arf__subcmd__config__subcmd__help_commands() {
    local commands; commands=(
'init:Generate a default configuration file' \
'check:Validate the configuration file' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf config help commands' commands "$@"
}
(( $+functions[_arf__subcmd__config__subcmd__help__subcmd__check_commands] )) ||
_arf__subcmd__config__subcmd__help__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'arf config help check commands' commands "$@"
}
(( $+functions[_arf__subcmd__config__subcmd__help__subcmd__help_commands] )) ||
_arf__subcmd__config__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'arf config help help commands' commands "$@"
}
(( $+functions[_arf__subcmd__config__subcmd__help__subcmd__init_commands] )) ||
_arf__subcmd__config__subcmd__help__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'arf config help init commands' commands "$@"
}
(( $+functions[_arf__subcmd__config__subcmd__init_commands] )) ||
_arf__subcmd__config__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'arf config init commands' commands "$@"
}
(( $+functions[_arf__subcmd__headless_commands] )) ||
_arf__subcmd__headless_commands() {
    local commands; commands=()
    _describe -t commands 'arf headless commands' commands "$@"
}
(( $+functions[_arf__subcmd__help_commands] )) ||
_arf__subcmd__help_commands() {
    local commands; commands=(
'completions:Generate shell completion scripts' \
'config:Configuration management' \
'history:History management' \
'ipc:Interact with a running arf session via IPC' \
'headless:Run R with IPC server only (no interactive REPL)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf help commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__completions_commands] )) ||
_arf__subcmd__help__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'arf help completions commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__config_commands] )) ||
_arf__subcmd__help__subcmd__config_commands() {
    local commands; commands=(
'init:Generate a default configuration file' \
'check:Validate the configuration file' \
    )
    _describe -t commands 'arf help config commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__config__subcmd__check_commands] )) ||
_arf__subcmd__help__subcmd__config__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'arf help config check commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__config__subcmd__init_commands] )) ||
_arf__subcmd__help__subcmd__config__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'arf help config init commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__headless_commands] )) ||
_arf__subcmd__help__subcmd__headless_commands() {
    local commands; commands=()
    _describe -t commands 'arf help headless commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__help_commands] )) ||
_arf__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'arf help help commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__history_commands] )) ||
_arf__subcmd__help__subcmd__history_commands() {
    local commands; commands=(
'schema:Display history database schema and example R code' \
'import:Import history from another source (experimental)' \
'export:Export history to a unified SQLite file (experimental)' \
    )
    _describe -t commands 'arf help history commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__history__subcmd__export_commands] )) ||
_arf__subcmd__help__subcmd__history__subcmd__export_commands() {
    local commands; commands=()
    _describe -t commands 'arf help history export commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__history__subcmd__import_commands] )) ||
_arf__subcmd__help__subcmd__history__subcmd__import_commands() {
    local commands; commands=()
    _describe -t commands 'arf help history import commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__history__subcmd__schema_commands] )) ||
_arf__subcmd__help__subcmd__history__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'arf help history schema commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc_commands] )) ||
_arf__subcmd__help__subcmd__ipc_commands() {
    local commands; commands=(
'list:List active arf sessions as JSON' \
'eval:Evaluate R code and return captured output as JSON' \
'send:Send code as user input to a running session' \
'session:Get session information as JSON (arf + R environment)' \
'shutdown:Shut down a running arf headless session (returns JSON \`{"accepted"\: true}\`)' \
'history:Query command history from a running session' \
    )
    _describe -t commands 'arf help ipc commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc__subcmd__eval_commands] )) ||
_arf__subcmd__help__subcmd__ipc__subcmd__eval_commands() {
    local commands; commands=()
    _describe -t commands 'arf help ipc eval commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc__subcmd__history_commands] )) ||
_arf__subcmd__help__subcmd__ipc__subcmd__history_commands() {
    local commands; commands=()
    _describe -t commands 'arf help ipc history commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc__subcmd__list_commands] )) ||
_arf__subcmd__help__subcmd__ipc__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'arf help ipc list commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc__subcmd__send_commands] )) ||
_arf__subcmd__help__subcmd__ipc__subcmd__send_commands() {
    local commands; commands=()
    _describe -t commands 'arf help ipc send commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc__subcmd__session_commands] )) ||
_arf__subcmd__help__subcmd__ipc__subcmd__session_commands() {
    local commands; commands=()
    _describe -t commands 'arf help ipc session commands' commands "$@"
}
(( $+functions[_arf__subcmd__help__subcmd__ipc__subcmd__shutdown_commands] )) ||
_arf__subcmd__help__subcmd__ipc__subcmd__shutdown_commands() {
    local commands; commands=()
    _describe -t commands 'arf help ipc shutdown commands' commands "$@"
}
(( $+functions[_arf__subcmd__history_commands] )) ||
_arf__subcmd__history_commands() {
    local commands; commands=(
'schema:Display history database schema and example R code' \
'import:Import history from another source (experimental)' \
'export:Export history to a unified SQLite file (experimental)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf history commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__export_commands] )) ||
_arf__subcmd__history__subcmd__export_commands() {
    local commands; commands=()
    _describe -t commands 'arf history export commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__help_commands] )) ||
_arf__subcmd__history__subcmd__help_commands() {
    local commands; commands=(
'schema:Display history database schema and example R code' \
'import:Import history from another source (experimental)' \
'export:Export history to a unified SQLite file (experimental)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf history help commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__help__subcmd__export_commands] )) ||
_arf__subcmd__history__subcmd__help__subcmd__export_commands() {
    local commands; commands=()
    _describe -t commands 'arf history help export commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__help__subcmd__help_commands] )) ||
_arf__subcmd__history__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'arf history help help commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__help__subcmd__import_commands] )) ||
_arf__subcmd__history__subcmd__help__subcmd__import_commands() {
    local commands; commands=()
    _describe -t commands 'arf history help import commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__help__subcmd__schema_commands] )) ||
_arf__subcmd__history__subcmd__help__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'arf history help schema commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__import_commands] )) ||
_arf__subcmd__history__subcmd__import_commands() {
    local commands; commands=()
    _describe -t commands 'arf history import commands' commands "$@"
}
(( $+functions[_arf__subcmd__history__subcmd__schema_commands] )) ||
_arf__subcmd__history__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'arf history schema commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc_commands] )) ||
_arf__subcmd__ipc_commands() {
    local commands; commands=(
'list:List active arf sessions as JSON' \
'eval:Evaluate R code and return captured output as JSON' \
'send:Send code as user input to a running session' \
'session:Get session information as JSON (arf + R environment)' \
'shutdown:Shut down a running arf headless session (returns JSON \`{"accepted"\: true}\`)' \
'history:Query command history from a running session' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf ipc commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__eval_commands] )) ||
_arf__subcmd__ipc__subcmd__eval_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc eval commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help_commands] )) ||
_arf__subcmd__ipc__subcmd__help_commands() {
    local commands; commands=(
'list:List active arf sessions as JSON' \
'eval:Evaluate R code and return captured output as JSON' \
'send:Send code as user input to a running session' \
'session:Get session information as JSON (arf + R environment)' \
'shutdown:Shut down a running arf headless session (returns JSON \`{"accepted"\: true}\`)' \
'history:Query command history from a running session' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'arf ipc help commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__eval_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__eval_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help eval commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__help_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help help commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__history_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__history_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help history commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__list_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help list commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__send_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__send_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help send commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__session_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__session_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help session commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__help__subcmd__shutdown_commands] )) ||
_arf__subcmd__ipc__subcmd__help__subcmd__shutdown_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc help shutdown commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__history_commands] )) ||
_arf__subcmd__ipc__subcmd__history_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc history commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__list_commands] )) ||
_arf__subcmd__ipc__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc list commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__send_commands] )) ||
_arf__subcmd__ipc__subcmd__send_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc send commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__session_commands] )) ||
_arf__subcmd__ipc__subcmd__session_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc session commands' commands "$@"
}
(( $+functions[_arf__subcmd__ipc__subcmd__shutdown_commands] )) ||
_arf__subcmd__ipc__subcmd__shutdown_commands() {
    local commands; commands=()
    _describe -t commands 'arf ipc shutdown commands' commands "$@"
}

if [ "$funcstack[1]" = "_arf" ]; then
    _arf "$@"
else
    compdef _arf arf
fi
