about summary refs log tree commit diff
path: root/Completion/Unix/Command/_perldoc
blob: 3e58d5a5068d29e029f3b0a1bbcdc0c26a7444ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#compdef perldoc -value-,PERLDOC,-default-

local curcontext="$curcontext" state line expl args ret=1
typeset -A opt_args

args=( '*:Perl pod pages:->perl-pods' )

if [[ $service = *PERLDOC* ]]; then
  compset -q
  words=( fake "$words[@]" )
  (( CURRENT++ ))
  args=()
fi

_arguments -C -s -S -A "-*" \
  '(- *)-h[print help information]' \
  '(- *)-V[display version information]' \
  '-D[describe search for the item]' \
  '-t[use plain text output instead of nroff]' \
  '-u[show raw Pod source]' \
  '*-m[display entire module]:module:_perl_modules' \
  '-l[display only filename of the module found]' \
  '-F[consider arguments as filenames]' \
  '(-q -v)-f+[view documentation for Perl built-in function]:perl builtin function:->perl-builtin-funcs' \
  '(-f -v)-q+[search question headings in Perl FAQ]:regular expression' \
  '(-f -q)-v+[view documentation for predefined variable]:special variable:->perl-variables' \
  '(-d)-T[send output direct to stdout and not via pager]' \
  '(-T)-d+[specify output file]:output file:_files' \
  '-o+[specify output format]:output format:(man nroff pod rtf text tk xml latex)' \
  '-M[specifies module to use for formatting]:module:_perl_modules' \
  '-w[specify option to formatter]:option' \
  '-X[use an index if present]' \
  '-n+[specify replacement for nroff]:nroff replacement:_command_names -e' \
  '-r[recursive search]' \
  '-i[ignore case]' \
  "$args[@]" && ret=0

case  $state in
  perl-builtin-funcs)
    : ${(A)_perl_builtin_funcs:=${(u)${${(M)${(f)"$(_call_program functions \
	perldoc -u perlfunc 2>/dev/null)"}:#\=item [a-z]*}#* }%%[^a-z]*}}

    _wanted functions expl 'perl built-in function' compadd "$@" -a - \
	_perl_builtin_funcs && ret=0
  ;;

  perl-pods)
    if (( $+opt_args[-F] )); then
      _wanted files expl 'Perl modules and .pods' \
          _files -g "*.(pod|pm)(-.)" && ret=0
    else
      _alternative \
	'modules:module: _perl_modules -tP' \
	'pods:base pod: _perl_basepods' \
	'files:module or .pod file:_files -g "*.(pod|pm)(-.)"' && ret=0
    fi
  ;;

  perl-variables)
    : ${(A)_perl_special_vars:=${(u)${${${(M)${(f)"$(_call_program variables \
      perldoc -u perlvar 2>/dev/null)"}:#\=item [\$\@\%]*}#* }:#\$<I*}}}

    _wanted variables expl 'perl special variable' compadd "$@" -a - \
	_perl_special_vars && ret=0
  ;;
esac

return ret