1#compdef reprepro
2
3local context state line distfile
4typeset -A opt_args
5local -a codenames
6
7_arguments \
8  '(-h --help)'{-h,--help}'[display help]' \
9  '*'{-v,-V,--verbose}'[be more verbose]' \
10  '--silent[be less verbose]' \
11  '(-b --basedir)'{-b,--basedir}':basedir:_files -/' \
12  '--confdir:config dir:_files -/' \
13  '--distdir:dist dir:_files -/' \
14  '--logdir:log dir:_files -/' \
15  '--overridedir:override dir:_files -/' \
16  '--dbdir:db dir:_files -/' \
17  '--listdir:list dir:_files -/' \
18  '--methoddir:method dir:_files -/' \
19  '(-C --component)'{-C,--component}':component:(component1 component2)' \
20  '(-A --architecture)'{-A,--architecture}':architecture:(amd64 sparc)' \
21  '(-T --type)'{-T,--type}':file type:(dsc deb udeb)' \
22  '(-S --section)'{-S,--section}':section:(section1 section2)' \
23  '(-P --priority)'{-P,--priority}':priority:(high low)' \
24  '--export=:whether and how:(never changed normal force)' \
25  '--ignore=:error type:(what otherwhat)' \
26  '--nolistsdownload[do not download Release or index files]' \
27  '--keepunreferencedfiles[do not delete files that are no longer used]' \
28  '--keepunneededlists' \
29  '--keepdirectories' \
30  '--ask-passphrase' \
31  '--noskipold' \
32  '--waitforlock:count:' \
33  '--spacecheck:behavior:(full none)' \
34  '--dbsafetymargin:bytes count:' \
35  '--safetymargin:bytes count:' \
36  '--noguessgpgtty' \
37  ':reprepro command:(export createsymlinks list listfilter remove update
38    iteratedupdate checkupdate predelete pull checkpull includedeb
39    includeudeb includedsc include processincoming check checkpool
40    rereference dumpreferences dumpunreferenced deleteunreferenced
41    reoverride dumptracks retrack removealltracks removetrack tidytracks
42    copy clearvanished gensnapshot rerunnotifiers)' \
43  '*::subcmd:->subcmd' && return 0
44
45case "$state" in
46    (subcmd)
47
48  case "$words[1]" in
49      (export|update|iteratedupdate|checkupdate|predelete|pull|checkpull|check)
50        if [[ -n "$opt_args[--confdir]" ]]; then
51	  distfile=${opt_args[--confdir]}/distributions
52	elif [[ -n "$opt_args[-b]" ]]; then
53	  distfile=${opt_args[-b]}/conf/distributions
54	elif [[ -n "$opt_args[--basedir]" ]]; then
55	  distfile=${opt_args[--basedir]}/conf/distributions
56	elif [[ -n "$REPREPRO_BASE_DIR" ]]; then
57	  distfile=${REPREPRO_BASE_DIR}/conf/distributions
58	else
59	  distfile=$PWD/conf/distributions
60	fi
61
62        codenames=($(awk '/^[Cc][Oo][Dd][Ee][Nn][Aa][Mm][Ee]: / {$1="";print}' "$distfile"))
63      	_wanted -V 'codenames' expl 'codename' compadd -a codenames
64	;;
65      (*)
66    	_files
67    	;;
68  esac
69  ;;
70esac
71