#compdef pdfgrep

# Zsh completion for pdfgrep.

# Copyright (C) 2015 by Hans-Peter Deifel (hpd@hpdeifel.de)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA.

typeset -A opt_args

local context state line

_arguments -s -S \
    "(-n --page-number)"{-n,--page-number}"[Prefix match with page number]" \
    "(-i --ignore-case)"{-i,--ignore-case}"[Ignore case distinctions]" \
    "(-F --fixed-strings)"{-F,--fixed-strings}"[Use literal strings]" \
    "(-P --perl-regexp)"{-P,--perl-regexp}"[Use Perl compatible regular expression syntax]" \
    "(-H --with-filename -h --no-filename)"{-H,--with-filename}"[Print filename for each match]" \
    "(-h --no-filename -H --with-filename)"{-h,--no-filename}"[Don't print filename]" \
    "(-c --count)"{-c,--count}"[Print only a count of matches per file]" \
    "(-p --page-count)"{-p,--page-count}"[Count matches per page]" \
    "(--color)--color=[Use colors for highlighting]:Color:(always never auto)" \
    "(-C --context)"{-C,--context=}"[Limit output]:Context:" \
    "(-r -R --recursive)"{-r,-R,--recursive}"[Search directories recursively]" \
    "*--exclude=[Skip files]:Exclude:" \
    "*--include=[Opposite of exclude]:Include:" \
    "(--help)--help[show a short help message]" \
    "(-V --version)"{-V,--version}"[Show version information]" \
    "(-q --quiet)"{-q,--quiet}"[Suppress all normal output]" \
    "(-Z --null)"{-Z,--null}"[Replace colon after filename by null byte]" \
    "(--match-prefix-separator)--match-prefix-separator=[Separator between filename, page and text]:Separator:" \
    "*--password=[Password to encrypt file]:Password:" \
    "(-m --max-count)"{-m,--max-count=}"[Process at most count matches]:Count:" \
    "(--debug)"--debug"[Enable debug output]" \
    "(--warn-empty)"--warn-empty"[Warn if a PDF file contains no text]" \
    "(--unac)--unac[Remove accents and ligatures]" \
    "1:pattern:()" \
    "*:pdf file:_files -g \"*.pdf\"" \
    && return 0

return 1
