#compdef rclone

# ------------------------------------------------------------------------------
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the zsh-users nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for rclone (http://rclone.org/).
#
# ------------------------------------------------------------------------------
# Author(s)
# -------
#
#  * Rajat Roy <i3wm.debian@gmail.com>
#
# ------------------------------------------------------------------------------ 

_rclone() { 
	local state
	
	_arguments \
		'1: :->subcommand' \
		'--bwlimit' \
		'--checkers' \
		'(-c --checksum)'{-c,--checksum}'[check the file hash and size to determine if files are equal]' \
		'--config' \
		'--contimeout' \
		'--dedupe-mode' \
		'(-n --dry-run)'{-n,--dry-run}'[Do a trial run with no permanent changes]' \
		'--ignore-existing' \
		'--ignore-size' \
		'(-I --ignore-times)'{-I,--ignore-times}'[unconditionally upload all files regardless of the state of files on the destination]' \
		'--log-file' \
		'--low-level-retries' \
		'--max-depth' \
		'--modify-window' \
		'--no-gzip-encoding' \
		'--no-update-modtime' \
		'(-q --quiet)'{-q,--quiet}'[as little output as possible]' \
		'--retries' \
		'--size-only' \
		'--stats' \
		'--delete-' \
		'--timeout' \
		'--transfers' \
		'(-u --update)'{-u,--update}'[skip any files which exist on the destination and have a modified time that is newer than the source file]' \
		'(-v --verbose)'{-v,--verbose}'[tells you about every file it considers and transfers]' \
		'--delete-excluded' \
		'--filter' \
		'--filter-from' \
		'-exclude' \
		'--exclude-from' \
		'--include' \
		'--include-from' \
		'--files-from' \
		'--min-size' \
		'--max-size' \
		'--min-age' \
		'--max-age' \
		'--dump-filters' \
		'*:files:_files'
		
	case $state in
		subcommand)
			_arguments '1: :(
				config
				copy
				sync
				move
				delete
				purge
				mkdir
				rmdir
				check
				ls
				lsd
				lsl
				md5sum
				sha1sum
				size
				version
				cleanup
				dedupe
				authorize
				cat
				genautocomplete
				gendocs
				listremotes
				mount
				--help)'
		;;
	esac
}
 
_rclone "$@"
