_folderify() {
    local i cur prev opts cmd
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    cmd=""
    opts=""

    for i in ${COMP_WORDS[@]}
    do
        case "${cmd},${i}" in
            ",$1")
                cmd="folderify"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        folderify)
            opts="-r -v -h -V --output-icns --output-iconset --reveal --macOS --color-scheme --no-trim --no-progress --set-icon-using --verbose --completions --help --version [MASK] [TARGET]"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --output-icns)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --output-iconset)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --macOS)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --color-scheme)
                    COMPREPLY=($(compgen -W "auto light dark" -- "${cur}"))
                    return 0
                    ;;
                --set-icon-using)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --completions)
                    COMPREPLY=($(compgen -W "bash elvish fish powershell zsh" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

complete -F _folderify -o bashdefault -o default folderify
