#compdef dotmorph
# zsh completion for dotmorph (generated by `dotmorph completions zsh`)
_dotmorph() {
    local -a cmds
    cmds=(
        'convert:convert files from the terminal'
        'formats:list supported conversions'
        'settings:open the settings window'
        'completions:shell completion script (bash, zsh, fish)'
        'doctor:check which tools are installed and what they unlock'
        'daemon:keep the wheel loaded so it opens instantly'
        'integrate:add DotMorph to file-manager right-click menus and Open With'
        'hotkey:global shortcut open the wheel with the copied files'
        'watch:convert new files in folders automatically'
    )
    if (( CURRENT == 2 )); then
        _describe -t commands 'dotmorph command' cmds
        _arguments '--theme[colour theme]:theme:(dark light glass)' '--reduce-motion[no animations]' '--clipboard[copied files]' '--no-daemon[new window]' '*:file:_files'
        return
    fi
    local sub=$words[2]
    words=(${words[2,-1]})
    (( CURRENT-- ))
    case $sub in
        convert)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--to[target format or tool]:to:(png jpg webp pdf avif gif mp4 mkv webm mov avi mp3 m4a ogg opus flac wav docx odt md html txt epub xlsx ods csv pptx odp bmp tiff ico compress resize-50 rotate-90 strip mute merge-pdf)' \
                '--preset[named set of options]:preset:(email print share thumb web)' \
                '(-o --out)'{-o,--out}'[output directory (default next to source)]:directory:_files -/' \
                '--dpi[render resolution (default PDF 150, SVG 96 = original size)]:dpi:' \
                '--quality[JPEG/WebP/AVIF quality (default 90)]:quality:' \
                '--resize[50%, 1920x1080 (fit inside) or 1280 (width)]:SPEC:' \
                '--strip[drop EXIF / tags while converting]' \
                '--overwrite[replace existing files]' \
                '(-j --jobs)'{-j,--jobs}'[files converted in parallel (default CPU cores, up to 8)]:jobs:' \
                '--timeout[give up on one file after N seconds]:timeout:' \
                '(-q --quiet)'{-q,--quiet}'[no progress bar]' \
                '--notify[desktop notification when done (with an Open folder button)]' \
                '(-n --dry-run)'{-n,--dry-run}'[show what would be converted, and how, without doing it]' \
                '*:file:_files'
            ;;
        formats)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--missing[what installing the missing tools would add]' \
                '*:file:_files'
            ;;
        settings)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]'
            ;;
        completions)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--install[write it where your shell picks it up (per user)]' \
                '1:shell:(bash zsh fish)'
            ;;
        doctor)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]'
            ;;
        daemon)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--install[start now and at every login]' \
                '--uninstall[stop and remove from login]' \
                '--stop[stop the running daemon]' \
                '--status[is it running?]' \
                '--theme[override the theme from the settings]:theme:(dark light glass)'
            ;;
        integrate)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--remove[take everything out again]'
            ;;
        hotkey)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--key[e.g. <Super><Shift>m (the default) or <Control><Alt>c]:key:' \
                '--force[even if the key is already taken]' \
                '--remove[remove the shortcut]'
            ;;
        watch)
            _arguments -s \
                '(-h --help)'{-h,--help}'[show this help message and exit]' \
                '--to[target format or tool]:to:(png jpg webp pdf avif gif mp4 mkv webm mov avi mp3 m4a ogg opus flac wav docx odt md html txt epub xlsx ods csv pptx odp bmp tiff ico compress resize-50 rotate-90 strip mute merge-pdf)' \
                '--from[only these source formats, comma separated (default all that fit)]:EXTS:' \
                '(-o --out)'{-o,--out}'[output directory (default same folder)]:directory:_files -/' \
                '--quality[]:quality:' \
                '--resize[]:SPEC:' \
                '--strip[]' \
                '(-r --recursive)'{-r,--recursive}'[watch sub-folders too]' \
                '--notify[notification for each file]' \
                '--install[run as a systemd user service]' \
                '--list[list installed watch services]' \
                '--uninstall[remove an installed watch service]:NAME:' \
                '*:file:_files'
            ;;
        *) _files ;;
    esac
}

_dotmorph "$@"
