#compdef mainline.py

# Mainline zsh completion script
#
# To install:
#   source /path/to/completion/mainline-completion.zsh
#
# Or add to ~/.zshrc:
#   source /path/to/completion/mainline-completion.zsh

# Define completion function
_mainline() {
    local -a commands
    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        '(-h --help)'{-h,--help}'[Show help]' \
        '--display=[Display backend]:backend:(terminal null replay websocket pygame moderngl)' \
        '--preset=[Preset to use]:preset:(demo demo-base demo-pygame demo-camera-showcase poetry headlines empty test-basic test-border test-scroll-camera test-figment test-message-overlay)' \
        '--viewport=[Viewport size]:size:(80x24 100x30 120x40 60x20)' \
        '--theme=[Color theme]:theme:(green orange purple blue red)' \
        '--websocket[Enable WebSocket server]' \
        '--websocket-port=[WebSocket port]:port:' \
        '--allow-unsafe[Allow unsafe pipeline configuration]' \
        '(-)*: :{_files}' \
        && ret=0

    # Handle --pipeline-* arguments
    if [[ -n ${words[*]} ]]; then
        _arguments -C \
            '--pipeline-source=[Data source]:source:(headlines poetry empty fixture pipeline-inspect)' \
            '--pipeline-effects=[Effect plugins]:effects:(afterimage border crop fade firehose glitch hud motionblur noise tint)' \
            '--pipeline-camera=[Camera mode]:camera:(feed scroll horizontal omni floating bounce radial)' \
            '--pipeline-display=[Display backend]:backend:(terminal null replay websocket pygame moderngl)' \
            '--pipeline-ui[Enable UI panel]' \
            '--pipeline-border=[Border mode]:mode:(off simple ui)' \
            '--viewport=[Viewport size]:size:(80x24 100x30 120x40 60x20)' \
            && ret=0
    fi

    return ret
}

# Register completion function
compdef _mainline mainline.py
compdef _mainline "python -m engine.app"
compdef _mainline "python -m mainline"
