#compdef shadowenv

autoload -U is-at-least

_shadowenv() {
    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[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_shadowenv_commands" \
"*::: :->shadowenv" \
&& ret=0
    case $state in
    (shadowenv)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:shadowenv-command-$line[1]:"
        case $line[1] in
            (diff)
_arguments "${_arguments_options[@]}" : \
'-n[Do not use color to highlight the diff]' \
'--no-color[Do not use color to highlight the diff]' \
'-v[Show all environment variables, not just those that change]' \
'--verbose[Show all environment variables, not just those that change]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(exec)
_arguments "${_arguments_options[@]}" : \
'--dir=[Instead of searching from the current directory for a .shadowenv.d, search from this one]:DIR: ' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::cmd_argv0 -- The command to execute if there are no arguments:' \
'*::cmd_argv -- The command and arguments if it has any:' \
&& ret=0
;;
(hook)
_arguments "${_arguments_options[@]}" : \
'--shellpid=[Rather than looking up the PPID, use this as the shell'\''s pid]:SHELLPID: ' \
'-f[Force the shadowenv to be applied, even if the working directory has not changed]' \
'--force[Force the shadowenv to be applied, even if the working directory has not changed]' \
'-s[Suppress error printing]' \
'--silent[Suppress error printing]' \
'--clobber[Clobber overridden environment variables when unshadowing]' \
'--posix[Format variable assignments for posix shells (default)]' \
'--porcelain[Format variable assignments for machine parsing]' \
'--fish[Format variable assignments for fish shell]' \
'--json[Format variable assignments as JSON]' \
'--pretty-json[Format variable assignments as pretty JSON]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_shadowenv__init_commands" \
"*::: :->init" \
&& ret=0

    case $state in
    (init)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:shadowenv-init-command-$line[1]:"
        case $line[1] in
            (bash)
_arguments "${_arguments_options[@]}" : \
'--no-hookbook[Don'\''t print hookbook inline (it'\''s still required -- only use if you'\''ve already loaded it)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(zsh)
_arguments "${_arguments_options[@]}" : \
'--no-hookbook[Don'\''t print hookbook inline (it'\''s still required -- only use if you'\''ve already loaded it)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(fish)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(nushell)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
        esac
    ;;
esac
;;
(trust)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(prompt-widget)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_shadowenv__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:shadowenv-help-command-$line[1]:"
        case $line[1] in
            (diff)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(exec)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(hook)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" : \
":: :_shadowenv__help__init_commands" \
"*::: :->init" \
&& ret=0

    case $state in
    (init)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:shadowenv-help-init-command-$line[1]:"
        case $line[1] in
            (bash)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(zsh)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(fish)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(nushell)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(trust)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(prompt-widget)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_shadowenv_commands] )) ||
_shadowenv_commands() {
    local commands; commands=(
'diff:Display a diff of changed environment variables' \
'exec:Execute a command after loading the environment from the current directory' \
'hook:Runs the shell hook. You shouldn'\''t need to run this manually' \
'init:Prints a script which can be eval'\''d to set up shadowenv in various shells' \
'trust:Mark this directory as '\''trusted'\'', allowing shadowenv programs to be run' \
'prompt-widget:Print a little glyph you can include in a shell prompt to indicate that shadowenv is active' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'shadowenv commands' commands "$@"
}
(( $+functions[_shadowenv__diff_commands] )) ||
_shadowenv__diff_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv diff commands' commands "$@"
}
(( $+functions[_shadowenv__exec_commands] )) ||
_shadowenv__exec_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv exec commands' commands "$@"
}
(( $+functions[_shadowenv__help_commands] )) ||
_shadowenv__help_commands() {
    local commands; commands=(
'diff:Display a diff of changed environment variables' \
'exec:Execute a command after loading the environment from the current directory' \
'hook:Runs the shell hook. You shouldn'\''t need to run this manually' \
'init:Prints a script which can be eval'\''d to set up shadowenv in various shells' \
'trust:Mark this directory as '\''trusted'\'', allowing shadowenv programs to be run' \
'prompt-widget:Print a little glyph you can include in a shell prompt to indicate that shadowenv is active' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'shadowenv help commands' commands "$@"
}
(( $+functions[_shadowenv__help__diff_commands] )) ||
_shadowenv__help__diff_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help diff commands' commands "$@"
}
(( $+functions[_shadowenv__help__exec_commands] )) ||
_shadowenv__help__exec_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help exec commands' commands "$@"
}
(( $+functions[_shadowenv__help__help_commands] )) ||
_shadowenv__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help help commands' commands "$@"
}
(( $+functions[_shadowenv__help__hook_commands] )) ||
_shadowenv__help__hook_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help hook commands' commands "$@"
}
(( $+functions[_shadowenv__help__init_commands] )) ||
_shadowenv__help__init_commands() {
    local commands; commands=(
'bash:Prints a script which can be eval'\''d by bash to set up shadowenv' \
'zsh:Prints a script which can be eval'\''d by zsh to set up shadowenv' \
'fish:Prints a script which can be eval'\''d by fish to set up shadowenv' \
'nushell:Prints a script which can be eval'\''d by nushell to set up shadowenv' \
    )
    _describe -t commands 'shadowenv help init commands' commands "$@"
}
(( $+functions[_shadowenv__help__init__bash_commands] )) ||
_shadowenv__help__init__bash_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help init bash commands' commands "$@"
}
(( $+functions[_shadowenv__help__init__fish_commands] )) ||
_shadowenv__help__init__fish_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help init fish commands' commands "$@"
}
(( $+functions[_shadowenv__help__init__nushell_commands] )) ||
_shadowenv__help__init__nushell_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help init nushell commands' commands "$@"
}
(( $+functions[_shadowenv__help__init__zsh_commands] )) ||
_shadowenv__help__init__zsh_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help init zsh commands' commands "$@"
}
(( $+functions[_shadowenv__help__prompt-widget_commands] )) ||
_shadowenv__help__prompt-widget_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help prompt-widget commands' commands "$@"
}
(( $+functions[_shadowenv__help__trust_commands] )) ||
_shadowenv__help__trust_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv help trust commands' commands "$@"
}
(( $+functions[_shadowenv__hook_commands] )) ||
_shadowenv__hook_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv hook commands' commands "$@"
}
(( $+functions[_shadowenv__init_commands] )) ||
_shadowenv__init_commands() {
    local commands; commands=(
'bash:Prints a script which can be eval'\''d by bash to set up shadowenv' \
'zsh:Prints a script which can be eval'\''d by zsh to set up shadowenv' \
'fish:Prints a script which can be eval'\''d by fish to set up shadowenv' \
'nushell:Prints a script which can be eval'\''d by nushell to set up shadowenv' \
    )
    _describe -t commands 'shadowenv init commands' commands "$@"
}
(( $+functions[_shadowenv__init__bash_commands] )) ||
_shadowenv__init__bash_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv init bash commands' commands "$@"
}
(( $+functions[_shadowenv__init__fish_commands] )) ||
_shadowenv__init__fish_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv init fish commands' commands "$@"
}
(( $+functions[_shadowenv__init__nushell_commands] )) ||
_shadowenv__init__nushell_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv init nushell commands' commands "$@"
}
(( $+functions[_shadowenv__init__zsh_commands] )) ||
_shadowenv__init__zsh_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv init zsh commands' commands "$@"
}
(( $+functions[_shadowenv__prompt-widget_commands] )) ||
_shadowenv__prompt-widget_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv prompt-widget commands' commands "$@"
}
(( $+functions[_shadowenv__trust_commands] )) ||
_shadowenv__trust_commands() {
    local commands; commands=()
    _describe -t commands 'shadowenv trust commands' commands "$@"
}

if [ "$funcstack[1]" = "_shadowenv" ]; then
    _shadowenv "$@"
else
    compdef _shadowenv shadowenv
fi
