#compdef tracexec

autoload -U is-at-least

_tracexec() {
    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[@]}" : \
'--color=[Control whether colored output is enabled. This flag has no effect on TUI mode.]:COLOR:(auto always never)' \
'-C+[Change current directory to this path before doing anything]:CWD:_files' \
'--cwd=[Change current directory to this path before doing anything]:CWD:_files' \
'(--no-profile)-P+[Load profile from this path]:PROFILE:_files' \
'(--no-profile)--profile=[Load profile from this path]:PROFILE:_files' \
'-u+[Run as user. This option is only available when running tracexec as root]:USER:_default' \
'--user=[Run as user. This option is only available when running tracexec as root]:USER:_default' \
'--no-profile[Do not load profiles]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_tracexec_commands" \
"*::: :->tracexec" \
&& ret=0
    case $state in
    (tracexec)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:tracexec-command-$line[1]:"
        case $line[1] in
            (log)
_arguments "${_arguments_options[@]}" : \
'--inline-timestamp-format=[Set the format of inline timestamp. See https\://docs.rs/chrono/latest/chrono/format/strftime/index.html for available options.]:INLINE_TIMESTAMP_FORMAT:_default' \
'--seccomp-bpf=[Controls whether to enable seccomp-bpf optimization, which greatly improves performance]:SECCOMP_BPF:(auto on off)' \
'--polling-interval=[Polling interval, in microseconds. -1(default) disables polling.]:POLLING_INTERVAL:_default' \
'--filter=[Set the default filter for events.]:FILTER:_default' \
'--filter-include=[Aside from the default filter, also include the events specified here.]:FILTER_INCLUDE:_default' \
'--filter-exclude=[Exclude the events specified here from the default filter.]:FILTER_EXCLUDE:_default' \
'-o+[Output, stderr by default. A single hyphen '\''-'\'' represents stdout.]:OUTPUT:_files' \
'--output=[Output, stderr by default. A single hyphen '\''-'\'' represents stdout.]:OUTPUT:_files' \
'(--less-colors)--more-colors[More colors]' \
'(--more-colors)--less-colors[Less colors]' \
'(--show-env --diff-env --show-argv --no-show-cmdline)--show-cmdline[Print commandline that (hopefully) reproduces what was executed. Note\: file descriptors are not handled for now.]' \
'--no-show-cmdline[Don'\''t print commandline that (hopefully) reproduces what was executed.]' \
'(--no-show-interpreter)--show-interpreter[Try to show script interpreter indicated by shebang]' \
'(--show-interpreter)--no-show-interpreter[Do not show script interpreter indicated by shebang]' \
'(--no-foreground)--foreground[Set the terminal foreground process group to tracee. This option is useful when tracexec is used interactively. \[default\]]' \
'(--foreground)--no-foreground[Do not set the terminal foreground process group to tracee]' \
'(--no-diff-fd)--diff-fd[Diff file descriptors with the original std{in/out/err}]' \
'(--diff-fd)--no-diff-fd[Do not diff file descriptors]' \
'(--diff-fd)--show-fd[Show file descriptors]' \
'(--show-fd)--no-show-fd[Do not show file descriptors]' \
'(--no-diff-env --show-env --no-show-env)--diff-env[Diff environment variables with the original environment]' \
'(--diff-env)--no-diff-env[Do not diff environment variables]' \
'(--no-show-env --diff-env)--show-env[Show environment variables]' \
'(--show-env)--no-show-env[Do not show environment variables]' \
'(--no-show-comm)--show-comm[Show comm]' \
'(--show-comm)--no-show-comm[Do not show comm]' \
'(--no-show-argv)--show-argv[Show argv]' \
'(--show-argv)--no-show-argv[Do not show argv]' \
'(--no-show-filename)--show-filename[Show filename]' \
'(--show-filename)--no-show-filename[Do not show filename]' \
'(--no-show-cwd)--show-cwd[Show cwd]' \
'(--show-cwd)--no-show-cwd[Do not show cwd]' \
'(--no-decode-errno)--decode-errno[Decode errno values]' \
'(--decode-errno)--no-decode-errno[Do not decode errno values]' \
'--successful-only[Only show successful calls]' \
'--fd-in-cmdline[\[Experimental\] Try to reproduce file descriptors in commandline. This might result in an unexecutable cmdline if pipes, sockets, etc. are involved.]' \
'--stdio-in-cmdline[\[Experimental\] Try to reproduce stdio in commandline. This might result in an unexecutable cmdline if pipes, sockets, etc. are involved.]' \
'--resolve-proc-self-exe[Resolve /proc/self/exe symlink]' \
'(--resolve-proc-self-exe)--no-resolve-proc-self-exe[Do not resolve /proc/self/exe symlink]' \
'--hide-cloexec-fds[Hide CLOEXEC fds]' \
'(--hide-cloexec-fds)--no-hide-cloexec-fds[Do not hide CLOEXEC fds]' \
'--timestamp[Show timestamp information]' \
'(--timestamp)--no-timestamp[Do not show timestamp information]' \
'(--filter)--show-all-events[Set the default filter to show all events. This option can be used in combination with --filter-exclude to exclude some unwanted events.]' \
'-h[Print help]' \
'--help[Print help]' \
'*::cmd -- command to be executed:_default' \
&& ret=0
;;
(tui)
_arguments "${_arguments_options[@]}" : \
'--inline-timestamp-format=[Set the format of inline timestamp. See https\://docs.rs/chrono/latest/chrono/format/strftime/index.html for available options.]:INLINE_TIMESTAMP_FORMAT:_default' \
'--seccomp-bpf=[Controls whether to enable seccomp-bpf optimization, which greatly improves performance]:SECCOMP_BPF:(auto on off)' \
'--polling-interval=[Polling interval, in microseconds. -1(default) disables polling.]:POLLING_INTERVAL:_default' \
'--filter=[Set the default filter for events.]:FILTER:_default' \
'--filter-include=[Aside from the default filter, also include the events specified here.]:FILTER_INCLUDE:_default' \
'--filter-exclude=[Exclude the events specified here from the default filter.]:FILTER_EXCLUDE:_default' \
'-A+[Set the default active pane to use when TUI launches]:ACTIVE_PANE:(terminal events)' \
'--active-pane=[Set the default active pane to use when TUI launches]:ACTIVE_PANE:(terminal events)' \
'-L+[Set the layout of the TUI when it launches]:LAYOUT:(horizontal vertical)' \
'--layout=[Set the layout of the TUI when it launches]:LAYOUT:(horizontal vertical)' \
'-F+[Set the frame rate of the TUI (60 by default)]:FRAME_RATE:_default' \
'--frame-rate=[Set the frame rate of the TUI (60 by default)]:FRAME_RATE:_default' \
'-m+[Max number of events to keep in TUI (0=unlimited)]:MAX_EVENTS:_default' \
'--max-events=[Max number of events to keep in TUI (0=unlimited)]:MAX_EVENTS:_default' \
'-D+[Set the default external command to run when using "Detach, Stop and Run Command" feature in Hit Manager]:DEFAULT_EXTERNAL_COMMAND:_default' \
'--default-external-command=[Set the default external command to run when using "Detach, Stop and Run Command" feature in Hit Manager]:DEFAULT_EXTERNAL_COMMAND:_default' \
'*-b+[Add a new breakpoint to the tracer. This option can be used multiple times. The format is <syscall-stop>\:<pattern-type>\:<pattern>, where syscall-stop can be sysenter or sysexit, pattern-type can be argv-regex, in-filename or exact-filename. For example, sysexit\:in-filename\:/bash]:BREAKPOINTS:_default' \
'*--add-breakpoint=[Add a new breakpoint to the tracer. This option can be used multiple times. The format is <syscall-stop>\:<pattern-type>\:<pattern>, where syscall-stop can be sysenter or sysexit, pattern-type can be argv-regex, in-filename or exact-filename. For example, sysexit\:in-filename\:/bash]:BREAKPOINTS:_default' \
'--successful-only[Only show successful calls]' \
'--fd-in-cmdline[\[Experimental\] Try to reproduce file descriptors in commandline. This might result in an unexecutable cmdline if pipes, sockets, etc. are involved.]' \
'--stdio-in-cmdline[\[Experimental\] Try to reproduce stdio in commandline. This might result in an unexecutable cmdline if pipes, sockets, etc. are involved.]' \
'--resolve-proc-self-exe[Resolve /proc/self/exe symlink]' \
'(--resolve-proc-self-exe)--no-resolve-proc-self-exe[Do not resolve /proc/self/exe symlink]' \
'--hide-cloexec-fds[Hide CLOEXEC fds]' \
'(--hide-cloexec-fds)--no-hide-cloexec-fds[Do not hide CLOEXEC fds]' \
'--timestamp[Show timestamp information]' \
'(--timestamp)--no-timestamp[Do not show timestamp information]' \
'(--filter)--show-all-events[Set the default filter to show all events. This option can be used in combination with --filter-exclude to exclude some unwanted events.]' \
'-t[Allocate a pseudo terminal and show it alongside the TUI]' \
'--tty[Allocate a pseudo terminal and show it alongside the TUI]' \
'-f[Keep the event list scrolled to the bottom]' \
'--follow[Keep the event list scrolled to the bottom]' \
'(--kill-on-exit)--terminate-on-exit[Instead of waiting for the root child to exit, terminate when the TUI exits]' \
'--kill-on-exit[Instead of waiting for the root child to exit, kill when the TUI exits]' \
'-h[Print help]' \
'--help[Print help]' \
'*::cmd -- command to be executed:_default' \
&& ret=0
;;
(generate-completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell -- The shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(collect)
_arguments "${_arguments_options[@]}" : \
'--inline-timestamp-format=[Set the format of inline timestamp. See https\://docs.rs/chrono/latest/chrono/format/strftime/index.html for available options.]:INLINE_TIMESTAMP_FORMAT:_default' \
'--seccomp-bpf=[Controls whether to enable seccomp-bpf optimization, which greatly improves performance]:SECCOMP_BPF:(auto on off)' \
'--polling-interval=[Polling interval, in microseconds. -1(default) disables polling.]:POLLING_INTERVAL:_default' \
'-F+[the format for exported exec events]:FORMAT:(json-stream json)' \
'--format=[the format for exported exec events]:FORMAT:(json-stream json)' \
'-o+[Output, stderr by default. A single hyphen '\''-'\'' represents stdout.]:OUTPUT:_files' \
'--output=[Output, stderr by default. A single hyphen '\''-'\'' represents stdout.]:OUTPUT:_files' \
'--successful-only[Only show successful calls]' \
'--fd-in-cmdline[\[Experimental\] Try to reproduce file descriptors in commandline. This might result in an unexecutable cmdline if pipes, sockets, etc. are involved.]' \
'--stdio-in-cmdline[\[Experimental\] Try to reproduce stdio in commandline. This might result in an unexecutable cmdline if pipes, sockets, etc. are involved.]' \
'--resolve-proc-self-exe[Resolve /proc/self/exe symlink]' \
'(--resolve-proc-self-exe)--no-resolve-proc-self-exe[Do not resolve /proc/self/exe symlink]' \
'--hide-cloexec-fds[Hide CLOEXEC fds]' \
'(--hide-cloexec-fds)--no-hide-cloexec-fds[Do not hide CLOEXEC fds]' \
'--timestamp[Show timestamp information]' \
'(--timestamp)--no-timestamp[Do not show timestamp information]' \
'-p[prettify the output if supported]' \
'--pretty[prettify the output if supported]' \
'(--no-foreground)--foreground[Set the terminal foreground process group to tracee. This option is useful when tracexec is used interactively. \[default\]]' \
'(--foreground)--no-foreground[Do not set the terminal foreground process group to tracee]' \
'-h[Print help]' \
'--help[Print help]' \
'*::cmd -- command to be executed:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_tracexec__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:tracexec-help-command-$line[1]:"
        case $line[1] in
            (log)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(tui)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(generate-completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(collect)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_tracexec_commands] )) ||
_tracexec_commands() {
    local commands; commands=(
'log:Run tracexec in logging mode' \
'tui:Run tracexec in TUI mode, stdin/out/err are redirected to /dev/null by default' \
'generate-completions:Generate shell completions for tracexec' \
'collect:Collect exec events and export them' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'tracexec commands' commands "$@"
}
(( $+functions[_tracexec__collect_commands] )) ||
_tracexec__collect_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec collect commands' commands "$@"
}
(( $+functions[_tracexec__generate-completions_commands] )) ||
_tracexec__generate-completions_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec generate-completions commands' commands "$@"
}
(( $+functions[_tracexec__help_commands] )) ||
_tracexec__help_commands() {
    local commands; commands=(
'log:Run tracexec in logging mode' \
'tui:Run tracexec in TUI mode, stdin/out/err are redirected to /dev/null by default' \
'generate-completions:Generate shell completions for tracexec' \
'collect:Collect exec events and export them' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'tracexec help commands' commands "$@"
}
(( $+functions[_tracexec__help__collect_commands] )) ||
_tracexec__help__collect_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec help collect commands' commands "$@"
}
(( $+functions[_tracexec__help__generate-completions_commands] )) ||
_tracexec__help__generate-completions_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec help generate-completions commands' commands "$@"
}
(( $+functions[_tracexec__help__help_commands] )) ||
_tracexec__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec help help commands' commands "$@"
}
(( $+functions[_tracexec__help__log_commands] )) ||
_tracexec__help__log_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec help log commands' commands "$@"
}
(( $+functions[_tracexec__help__tui_commands] )) ||
_tracexec__help__tui_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec help tui commands' commands "$@"
}
(( $+functions[_tracexec__log_commands] )) ||
_tracexec__log_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec log commands' commands "$@"
}
(( $+functions[_tracexec__tui_commands] )) ||
_tracexec__tui_commands() {
    local commands; commands=()
    _describe -t commands 'tracexec tui commands' commands "$@"
}

if [ "$funcstack[1]" = "_tracexec" ]; then
    _tracexec "$@"
else
    compdef _tracexec tracexec
fi
