#compdef folderify

autoload -U is-at-least

_folderify() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'--output-icns=[Write the `.icns` file to the given path.
(Will be written even if a target is also specified.)]:ICNS_FILE:_files' \
'--output-iconset=[Write the `.iconset` folder to the given path.
(Will be written even if a target is also specified.)]:ICONSET_FOLDER:_files' \
'--macOS=[Version of the macOS folder icon, e.g. "10.13". Defaults to the version currently running]:MACOS_VERSION: ' \
'--color-scheme=[Color scheme — auto matches the current system value]:COLOR_SCHEME:(auto light dark)' \
'--set-icon-using=[Legacy argument. Now ignored]:SET_ICON_USING: ' \
'--completions=[Print completions for the given shell (instead of generating any icons).
These can be loaded/stored permanently (e.g. when using Homebrew), but they can also be sourced directly, e.g.:]:SHELL:(bash elvish fish powershell zsh)' \
'-r[Reveal either the target, `.icns`, or `.iconset` (in that order of preference) in Finder]' \
'--reveal[Reveal either the target, `.icns`, or `.iconset` (in that order of preference) in Finder]' \
'--no-trim[Don'\''t trim margins from the mask.
By default, transparent margins are trimmed from all 4 sides.]' \
'--no-progress[Don'\''t show progress bars]' \
'-v[Detailed output. Also sets `--no-progress`]' \
'--verbose[Detailed output. Also sets `--no-progress`]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'::mask -- Mask image file. For best results\:
- Use a .png mask.
- Use a solid black design over a transparent background.
- Make sure the corner pixels of the mask image are transparent. They are used for empty margins.
- Make sure the non-transparent pixels span a height of 384px, using a 16px grid.
If the height is 384px and the width is a multiple of 128px, each 64x64 tile will exactly align with 1 pixel at the smallest folder size.:_files' \
'::target -- Target file or folder. If a target is specified, the resulting icon will
be applied to the target file/folder. Else (unless --output-icns or
--output-iconset is specified), a .iconset folder and .icns file will be
created in the same folder as the mask (you can use "Get Info" in Finder
to copy the icon from the .icns file).:_files' \
&& ret=0
}

(( $+functions[_folderify_commands] )) ||
_folderify_commands() {
    local commands; commands=()
    _describe -t commands 'folderify commands' commands "$@"
}

if [ "$funcstack[1]" = "_folderify" ]; then
    _folderify "$@"
else
    compdef _folderify folderify
fi
