#compdef envio

autoload -U is-at-least

_envio() {
    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[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
":: :_envio_commands" \
"*::: :->envio" \
&& ret=0
    case $state in
    (envio)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:envio-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(create)
_arguments "${_arguments_options[@]}" : \
'-d+[optional note or description of the profile]:DESCRIPTION:_default' \
'--description=[optional note or description of the profile]:DESCRIPTION:_default' \
'-f+[file path to load environment variables from]:ENVS_FILE:_default' \
'--from-file=[file path to load environment variables from]:ENVS_FILE:_default' \
'*-e+[environment variables to add (format\: KEY=VALUE or only provide KEY and the value will be prompted for)]:ENVS:_default' \
'*--envs=[environment variables to add (format\: KEY=VALUE or only provide KEY and the value will be prompted for)]:ENVS:_default' \
'-k+[encryption cipher to use]:CIPHER_KIND:_default' \
'--cipher-kind=[encryption cipher to use]:CIPHER_KIND:_default' \
'-c[add comments to the provided environment variables]' \
'--comments[add comments to the provided environment variables]' \
'-x[add expiration dates to the provided environment variables]' \
'--expires[add expiration dates to the provided environment variables]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" : \
'-d+[optional note or description of the profile]:DESCRIPTION:_default' \
'--description=[optional note or description of the profile]:DESCRIPTION:_default' \
'-f+[file path to load environment variables from]:ENVS_FILE:_default' \
'--from-file=[file path to load environment variables from]:ENVS_FILE:_default' \
'*-e+[environment variables to add (format\: KEY=VALUE or only provide KEY and the value will be prompted for)]:ENVS:_default' \
'*--envs=[environment variables to add (format\: KEY=VALUE or only provide KEY and the value will be prompted for)]:ENVS:_default' \
'-k+[encryption cipher to use]:CIPHER_KIND:_default' \
'--cipher-kind=[encryption cipher to use]:CIPHER_KIND:_default' \
'-c[add comments to the provided environment variables]' \
'--comments[add comments to the provided environment variables]' \
'-x[add expiration dates to the provided environment variables]' \
'--expires[add expiration dates to the provided environment variables]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(delete)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'--no-pretty-print[disable pretty printing]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(ls)
_arguments "${_arguments_options[@]}" : \
'--no-pretty-print[disable pretty printing]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
'-c[display comments]' \
'--show-comments[display comments]' \
'-x[display expiration dates]' \
'--show-expiration[display expiration dates]' \
'--no-pretty-print[disable pretty printing]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(set)
_arguments "${_arguments_options[@]}" : \
'-c[add comments to the provided environment variables]' \
'--comments[add comments to the provided environment variables]' \
'-x[add expiration dates to the provided environment variables]' \
'--expires[add expiration dates to the provided environment variables]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
'*::envs -- environment variables to set (format\: KEY=VALUE or only provide KEY and the value will be prompted for):_default' \
&& ret=0
;;
(unset)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
'*::keys -- keys of environment variables to remove:_default' \
&& ret=0
;;
(shell)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
'*::command -- command to run:_default' \
&& ret=0
;;
(import)
_arguments "${_arguments_options[@]}" : \
'-n+[name for the imported profile]:PROFILE_NAME:_default' \
'--profile-name=[name for the imported profile]:PROFILE_NAME:_default' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':source -- source file or url:_default' \
&& ret=0
;;
(export)
_arguments "${_arguments_options[@]}" : \
'-o+[output file path (default\: .env)]:OUTPUT_FILE_PATH:_default' \
'--output-file-path=[output file path (default\: .env)]:OUTPUT_FILE_PATH:_default' \
'*-k+[comma-separated list of keys to export (type '\''select'\'' to choose interactively)]:KEYS:_default' \
'*--keys=[comma-separated list of keys to export (type '\''select'\'' to choose interactively)]:KEYS:_default' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(add-key)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(remove-key)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':profile_name -- name of the profile:_default' \
&& ret=0
;;
(tui)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completion)
_arguments "${_arguments_options[@]}" : \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
':shell -- shell to show completion for (bash, zsh, fish, powershell):(bash zsh fish powershell)' \
&& ret=0
;;
(version)
_arguments "${_arguments_options[@]}" : \
'-v[show verbose version information]' \
'--verbose[show verbose version information]' \
'--diagnostic[Show diagnostic information for bug reports]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_envio_commands] )) ||
_envio_commands() {
    local commands; commands=(
'init:Initialize envio to be used in the current project directory' \
'create:Create a new profile' \
'new:Create a new profile' \
'delete:Delete a profile' \
'remove:Delete a profile' \
'list:List all profiles' \
'ls:List all profiles' \
'show:Show environment variables in a profile' \
'set:Set or update environment variables in a profile' \
'unset:Remove environment variables from a profile' \
'shell:Spawn a new shell with environment variables loaded from the profile' \
'run:Run a command using environment variables from a profile' \
'import:Import a profile from a file or url' \
'export:Export the environment variables of a profile to a file' \
'add-key:Add a profile encryption key to the keyring' \
'remove-key:Remove a profile encryption key from the keyring' \
'tui:Launch the interactive TUI application' \
'completion:Show shell completion for the provided shell' \
'version:Print version information' \
    )
    _describe -t commands 'envio commands' commands "$@"
}
(( $+functions[_envio__add-key_commands] )) ||
_envio__add-key_commands() {
    local commands; commands=()
    _describe -t commands 'envio add-key commands' commands "$@"
}
(( $+functions[_envio__completion_commands] )) ||
_envio__completion_commands() {
    local commands; commands=()
    _describe -t commands 'envio completion commands' commands "$@"
}
(( $+functions[_envio__create_commands] )) ||
_envio__create_commands() {
    local commands; commands=()
    _describe -t commands 'envio create commands' commands "$@"
}
(( $+functions[_envio__delete_commands] )) ||
_envio__delete_commands() {
    local commands; commands=()
    _describe -t commands 'envio delete commands' commands "$@"
}
(( $+functions[_envio__export_commands] )) ||
_envio__export_commands() {
    local commands; commands=()
    _describe -t commands 'envio export commands' commands "$@"
}
(( $+functions[_envio__import_commands] )) ||
_envio__import_commands() {
    local commands; commands=()
    _describe -t commands 'envio import commands' commands "$@"
}
(( $+functions[_envio__init_commands] )) ||
_envio__init_commands() {
    local commands; commands=()
    _describe -t commands 'envio init commands' commands "$@"
}
(( $+functions[_envio__list_commands] )) ||
_envio__list_commands() {
    local commands; commands=()
    _describe -t commands 'envio list commands' commands "$@"
}
(( $+functions[_envio__remove-key_commands] )) ||
_envio__remove-key_commands() {
    local commands; commands=()
    _describe -t commands 'envio remove-key commands' commands "$@"
}
(( $+functions[_envio__run_commands] )) ||
_envio__run_commands() {
    local commands; commands=()
    _describe -t commands 'envio run commands' commands "$@"
}
(( $+functions[_envio__set_commands] )) ||
_envio__set_commands() {
    local commands; commands=()
    _describe -t commands 'envio set commands' commands "$@"
}
(( $+functions[_envio__shell_commands] )) ||
_envio__shell_commands() {
    local commands; commands=()
    _describe -t commands 'envio shell commands' commands "$@"
}
(( $+functions[_envio__show_commands] )) ||
_envio__show_commands() {
    local commands; commands=()
    _describe -t commands 'envio show commands' commands "$@"
}
(( $+functions[_envio__tui_commands] )) ||
_envio__tui_commands() {
    local commands; commands=()
    _describe -t commands 'envio tui commands' commands "$@"
}
(( $+functions[_envio__unset_commands] )) ||
_envio__unset_commands() {
    local commands; commands=()
    _describe -t commands 'envio unset commands' commands "$@"
}
(( $+functions[_envio__version_commands] )) ||
_envio__version_commands() {
    local commands; commands=()
    _describe -t commands 'envio version commands' commands "$@"
}

if [ "$funcstack[1]" = "_envio" ]; then
    _envio "$@"
else
    compdef _envio envio
fi

