# apt-ostree zsh completion
# Generated for apt-ostree version 0.1.0

_apt_ostree() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        '1: :->cmds' \
        '*:: :->args'

    case $state in
        cmds)
            local commands
            commands=(
                'info:Display detailed package information'
                'search:Search for packages in APT repositories'
                'install:Install packages and create new OSTree deployment'
                'remove:Remove packages and create new OSTree deployment'
                'upgrade:Upgrade all packages and create new OSTree deployment'
                'rollback:Rollback to previous OSTree deployment'
                'status:Show current OSTree deployment status'
                'help:Show help message'
                'version:Show version information'
            )
            _describe -t commands 'apt-ostree commands' commands
            ;;
        args)
            case $line[1] in
                info|install|remove)
                    # Complete with package names from APT cache
                    if (( $+commands[apt-cache] )); then
                        local packages
                        packages=($(apt-cache --no-generate pkgnames 2>/dev/null | grep -i "^$words[CURRENT]" | head -20))
                        _describe -t packages 'packages' packages
                    fi
                    ;;
                search)
                    # Complete with search terms
                    local search_terms
                    search_terms=(
                        'package:Search by package name'
                        'name:Search by package name'
                        'description:Search by package description'
                        'maintainer:Search by package maintainer'
                    )
                    _describe -t search_terms 'search terms' search_terms
                    ;;
                *)
                    # Global options
                    local global_opts
                    global_opts=(
                        '--help[Show help message]'
                        '--version[Show version information]'
                        '--verbose[Enable verbose output]'
                        '--quiet[Suppress non-error messages]'
                        '--config[Path to configuration file]:config file:_files -g "*.toml"'
                        '--data-dir[Path to data directory]:directory:_directories'
                        '--log-level[Set log level]:log level:(trace debug info warn error)'
                    )
                    _describe -t global_opts 'global options' global_opts
                    ;;
            esac
            ;;
    esac
}

# Register the completion function
compdef _apt_ostree apt-ostree

# Also complete for the short alias if it exists
compdef _apt_ostree aost 2>/dev/null || true
