#compdef cargo-watch

setopt localoptions extended_glob

local cmd
local -a args
local -a _comp_priv_prefix

cmd="$words[1]"

args=(
  '(-c --clear)'{-c,--clear}'[Clear screen before executing command]'
  '(-h --help)'{-h,--help}'[Print help information]'
  '(-V --version)'{-V,--version}'[Print version information]'
  '(-x --exec)'{-x+,--exec=}'[Cargo subcommand to execute on changes]:cargo-command'
  '(-s --shell)'{-s+,--shell=}'[Shell command to execute on changes]:command'
  '(-i --ignore)'{-i+,--ignore=}'[Ignore changes to paths matching the pattern]:pattern'
  '(-w --watch)'{-w+,--watch=}'[Watch a specific directory]:path:_path_files -/'
  '(-C --workdir)'{-C+,--workdir=}'[Change working directory of command]:path:_path_files -/'
  '-B=[Inject RUST_BACKTRACE=value into the environment]:value'
  '--no-ignore[Skip .ignore files]'
  '--no-gitignore[Skip .gitignore files]'
  '--ignore-nothing[Ignore nothing, not even target/ and .git/]'
  '--use-shell=[Change the wrapping shell]:program'
  '--postpone[Wait until first change to execute command]'
  '--no-restart[Do not restart while the command isstill running]'
  '--watch-when-idle[Ignore events while the command is still running]'
  '--quiet[Suppress all cargo-watch output]'
  '--debug[Print debugging to stderr]'
  '--why[Print changed paths to stderr]'
  '--delay=[File updates debounce delay]:seconds'
  '--poll=[Forces polling mode]:interval'
  '--features=[List of features passed to cargo invocations]:features'
  '(-)1:command: _command_names -e'
  '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[-u]} ) ; _normal }'
)

_arguments -s -S $args
