#compdef lzop

local expl state line decompress disp curcontext="$curcontext" sep ret=1
typeset -A opt_args

_arguments -C -s \
  '(-c --stdout --to-stdout)'{-c,--stdout,--to-stdout}'[write on standard output]' \
  '(-d --decompress --uncompress -x -extract)'{-d,--decompress,--uncompress}'[decompress]' \
  '(-x --extract -d --decompress --uncompress -n --name -p --path)'{-x,--extract}'[extract]' \
  '(-f --force)'{-f,--force}'[force overwrite]' \
  '(- *)'{-h,-H,--help}'[display help information]' \
  '(-l --list)'{-l,--list}'[list compressed file contents]' \
  '(-L --license)'{-L,--license}'[display software license]' \
  '(-n --no-name -N --name)'{-n,--no-name}'[do not save or restore the original name and time stamp]' \
  '(-N --name -n --no-name)'{-N,--name}'[save or restore the original name and time stamp]' \
  '--no-mode[do not restore original mode]' \
  '--no-time[do not restore original time stamp]' \
  '(-q --quiet --silent)'{-q,--quiet,--silent}'[suppress all warnings]' \
  '(-r --recursive)'{-r,--recursive}'[operate recursively on directories]' \
  '(-S --suffix)'{-S+,--suffix=}'[specify suffix for compressed files]:suffix' \
  '(-t --test)'{-t,--test}'[test compressed file integrity]' \
  \*{-v,--verbose}'[verbose mode]' \
  '(- *)'{-V,--version}'[display version number]' \
  '(       -1 -2 -3 -4 -5 -6 -7 -8 -9 --best)--fast' \
  '(--fast    -2 -3 -4 -5 -6 -7 -8 -9 --best)-1' \
  '(--fast -1    -3 -4 -5 -6 -7 -8 -9 --best)-2' \
  '(--fast -1 -2    -4 -5 -6 -7 -8 -9 --best)-3' \
  '(--fast -1 -2 -3    -5 -6 -7 -8 -9 --best)-4' \
  '(--fast -1 -2 -3 -4    -6 -7 -8 -9 --best)-5' \
  '(--fast -1 -2 -3 -4 -5    -7 -8 -9 --best)-6' \
  '(--fast -1 -2 -3 -4 -5 -6    -8 -9 --best)-7' \
  '(--fast -1 -2 -3 -4 -5 -6 -7    -9 --best)-8' \
  '(--fast -1 -2 -3 -4 -5 -6 -7 -8    --best)-9' \
  '(--fast -1 -2 -3 -4 -5 -6 -7 -8 -9       )--best' \
  '--ls=[list each compressed file in a format similar to ls -ln]:ls flag:->flags' \
  '--info[list internal header fields for each compressed file]' \
  '(-I --sysinfo)'{-I,--sysinfo}'[display information about the system]' \
  '(-o --outfile)'{-o,--outfile=}'[specify output file]:output file:_files' \
  '(-p --path)'{-p,--path=}'[write output files to specified directory]:directory:_files -/' \
  '(-F --no-checksum)'{-F,--no-checksum}'[do not store or verify a checksum]' \
  '(-k --keep -U --unlink --delete)'{-k,--keep}"[keep (don't delete) input files]" \
  '(-U --unlink --delete)'{-U,--unlink,--delete}'[delete input files]' \
  '--no-stdin[do not try to read stdin]' \
  '--no-warn[suppress all warnings]' \
  '--ignore-warn[suppress all warnings and never exit with status 2]' \
  '--no-color[do not use an color escape sequences]' \
  '--mono[assume a mono ANSI terminal]' \
  '--color[assume a color ANSI terminal]' \
  '--intro[display intro sequence]' \
  '--filter=[preprocess data with a special multimedia filter]:number' \
  '*:files:->files' && ret=0

case "$state" in
  files)
    if (( $+opt_args[-d] || $+opt_args[--decompress] ||
	$+opt_args[--uncompress] || $+opt_args[-x] || $+opt_args[--extract] ||
	$+opt_args[--test] || $+opt_args[-t] || $+opt_args[--list] ||
	$+opt_args[-l] || $+opt_args[--ls] || $+opt_args[--info] )); then
      _description files expl 'compressed file'
      _files "$expl[@]" -g '*.[tl]zo(-.)' && ret=0
    else
      _description files expl 'file to compress'
      _files "$expl[@]" -g '^*.[tl]zo(-.)' && ret=0
    fi
  ;;
  flags)
    zstyle -s ":completion:${curcontext}:flags" list-separator sep || sep=--
    disp=(
      "F $sep Append a \`*' for executable files"
      "G $sep Inhibit display of group information"
      "Q $sep Enclose file names in double quotes" )
    disp=( ${disp[@]:#[Z$PREFIX]*} )
    compset -P '[FGQ]*'
    compadd -d disp - ${disp[@]%% *} && ret=0
  ;;
esac

return ret
