#compdef mole mo

_mole() {
    local -a subcommands
    subcommands=(
        'clean:Free up disk space'
        'uninstall:Remove apps completely'
        'optimize:Refresh caches and services'
        'analyze:Explore disk usage'
        'status:Monitor system health'
        'purge:Remove old project artifacts'
        'installer:Find and remove installer files'
        'touchid:Configure Touch ID for sudo'
        'completion:Setup shell tab completion'
        'update:Update to latest version'
        'remove:Remove Mole from system'
        'help:Show help'
        'version:Show version'
    )
    if (( CURRENT == 2 )); then
        _describe 'subcommand' subcommands
        return
    fi
    case "$words[2]" in
        clean)
            _arguments \
                '--dry-run[Preview cleanup without making changes]' \
                '-n[Preview cleanup without making changes]' \
                '--external[Clean OS metadata from an external volume]:path:_files -/' \
                '--whitelist[Manage protected paths]' \
                '--debug[Show detailed logs]' \
                '(-h --help)'{-h,--help}'[Show help]'
            ;;
        analyze|analyse)
            _arguments \
                '--json[Output analysis as JSON]' \
                '(-h --help)'{-h,--help}'[Show help]' \
                '*:path:_files'
            ;;
        purge)
            _arguments \
                '--paths[Edit custom scan directories]' \
                '--dry-run[Preview purge actions without making changes]' \
                '-n[Preview purge actions without making changes]' \
                '--include-empty[Show zero-size project artifact directories]' \
                '--debug[Show detailed logs]' \
                '(-h --help)'{-h,--help}'[Show help]'
            ;;
        completion)
            _arguments '1:shell:(bash zsh fish)'
            ;;
        *)
            _describe 'subcommand' subcommands
            ;;
    esac
}

compdef _mole mole mo
