_uos_ste_eventctl() {
    local cur prev words cword
    _init_completion || return

    local commands="list logs show help"
    local global_opts="--config --log-path"
    
    if [[ $cword -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "${commands} ${global_opts}" -- "$cur") )
        return
    fi

    local subcommand=""
    local i
    for ((i=1; i < cword; i++)); do
        case "${words[i]}" in
            list|logs|show|help)
                subcommand="${words[i]}"
                break
                ;;
        esac
    done

    case "$prev" in
        --config)
            _filedir
            return
            ;;
        --log-path)
            _filedir -d
            return
            ;;
    esac

    if [[ -z "$subcommand" ]]; then
        COMPREPLY=( $(compgen -W "${commands} ${global_opts}" -- "$cur") )
        return
    fi

    case "$subcommand" in
        list)
            COMPREPLY=( $(compgen -W "--filter --all ${global_opts}" -- "$cur") )
            ;;
        logs)
            COMPREPLY=( $(compgen -W "--since --before --filter ${global_opts}" -- "$cur") )
            ;;
        show)
            if [[ "$cur" == -* ]]; then
                COMPREPLY=( $(compgen -W "--pretty ${global_opts}" -- "$cur") )
            fi
            ;;
        help)
            COMPREPLY=()
            ;;
    esac
}

complete -F _uos_ste_eventctl uos-ste-eventctl
