summaryrefslogtreecommitdiffstats
path: root/Completion/X/Command/_pdftk
blob: 4029e52fecbfac4466af36cb8cfbc54bc3ed12cd (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
#compdef pdftk

_pdfwithhandle()
{
    compset -P '(#I)[A-Z]='
    _files "$@" -g '(#i)*.pdf'
}

local -a expl opts operations

opts=(output encrypt_40bit encrypt_128bit allow owner_pw user_pw flatten
	compress uncompress keep_first_id keep_final_id drop_xfa verbose
	dont_ask do_ask)
operations=(cat attach_files unpack_files burst fill_form background stamp
	generate_fdf multibackground multistamp dump_data dump_data_fields
	update_info)

case $words[CURRENT-1] in
    ((input|owner|user)_pw)
	_message "password, or PROMPT"
	;;

    (allow)
	_values -s , permission \
	    Printing DegradedPrinting ModifyContents Assembly CopyContents \
	    ScreenReaders ModifyAnnotations FillIn AllFeatures
	;;

    (attach_files)
	_files
	;;

    (fill_form)
        _wanted files expl 'FDF or XFDF file' _files -g '(#i)*.(fdf|xfdf)(-.)'
	;;

    ((multibackground|background|stamp|multistamp|output))
	_pdf
	;;

    (update_info)
	_files
	;;

    (*)
	false
	;;
esac && return 0

if [[ -n $words[(r)(${(j:|:)operations})] ]]; then
  _wanted options expl "option" compadd -a opts
else
  _alternative \
    'files:PDF file:_pdfwithhandle' \
    "operations:operation:compadd -a operations"
fi