#compdef hecate-lampad

autoload -U is-at-least

_hecate-lampad() {
    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[@]}" : \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_hecate-lampad_commands" \
"*::: :->hecate-lampad" \
&& ret=0
    case $state in
    (hecate-lampad)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:hecate-lampad-command-$line[1]:"
        case $line[1] in
            (enroll)
_arguments "${_arguments_options[@]}" : \
'--server-url=[]:SERVER_URL:_default' \
'--token=[]:TOKEN:_default' \
'--token-file=[]:TOKEN_FILE:_files' \
'*--tags=[Custom machine tags (namespace\:value), comma-separated]:TAGS:_default' \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" : \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'--check[Check whether an update is available without applying it]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'--json[]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(forget)
_arguments "${_arguments_options[@]}" : \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(complete)
_arguments "${_arguments_options[@]}" : \
'--config=[Agent config file path]:CONFIG:_files' \
'--key-path=[Ed25519 private key file path]:KEY_PATH:_files' \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_hecate-lampad__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:hecate-lampad-help-command-$line[1]:"
        case $line[1] in
            (enroll)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(run)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(forget)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(complete)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_hecate-lampad_commands] )) ||
_hecate-lampad_commands() {
    local commands; commands=(
'enroll:Enroll this machine with the Hecate server (one-shot)' \
'run:Run the agent pull loop (long-running)' \
'update:Download and apply the latest server release for this agent' \
'status:Show enrollment and agent health status' \
'forget:Remove local enrollment material (config, key, runtime status)' \
'complete:Generate shell completion scripts to stdout' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'hecate-lampad commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__complete_commands] )) ||
_hecate-lampad__subcmd__complete_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad complete commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__enroll_commands] )) ||
_hecate-lampad__subcmd__enroll_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad enroll commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__forget_commands] )) ||
_hecate-lampad__subcmd__forget_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad forget commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help_commands] )) ||
_hecate-lampad__subcmd__help_commands() {
    local commands; commands=(
'enroll:Enroll this machine with the Hecate server (one-shot)' \
'run:Run the agent pull loop (long-running)' \
'update:Download and apply the latest server release for this agent' \
'status:Show enrollment and agent health status' \
'forget:Remove local enrollment material (config, key, runtime status)' \
'complete:Generate shell completion scripts to stdout' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'hecate-lampad help commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__complete_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__complete_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help complete commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__enroll_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__enroll_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help enroll commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__forget_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__forget_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help forget commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__help_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help help commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__run_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help run commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__status_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__status_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help status commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__help__subcmd__update_commands] )) ||
_hecate-lampad__subcmd__help__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad help update commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__run_commands] )) ||
_hecate-lampad__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad run commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__status_commands] )) ||
_hecate-lampad__subcmd__status_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad status commands' commands "$@"
}
(( $+functions[_hecate-lampad__subcmd__update_commands] )) ||
_hecate-lampad__subcmd__update_commands() {
    local commands; commands=()
    _describe -t commands 'hecate-lampad update commands' commands "$@"
}

if [ "$funcstack[1]" = "_hecate-lampad" ]; then
    _hecate-lampad "$@"
else
    compdef _hecate-lampad hecate-lampad
fi
