summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-dev/attachments/20110713/f8807b02/attachment.obj
blob: 3a0ac77e4851031278135eaaaa9e34c7a1233f49 (plain)
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
69
70
71
72
73
74
75
76
77
78
# mgarepo(1) completion
#
#_cooker_packages()
#{
#	COMPREPLY=( $( compgen -W '$(svn ls \
#		svn+ssh://svn.mandriva.com/svn/packages/cooker \
#		| sed -e "s|/$||" )' -- $cur ) )
#}

_mgarepo_actions()
{
	COMPREPLY=( $( compgen -W 'co ci authoremail changed create del \
		getspec getsrpm import maintdb putsrpm rpmlog submit \
		switch sync upload \
		 help' -- $cur ) )
}

_mgarepo()
{
	local cur prev command options i

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}

	if [[ $COMP_CWORD -eq 1 ]] ; then
		_mgarepo_actions
	else
		prev=${COMP_WORDS[COMP_CWORD-1]}

		case "$prev" in
			-@(c|-config))
				_filedir
				return 0
				;;
		esac

		command=${COMP_WORDS[1]}

		if [[ "$cur" == -* ]]; then
			# possible options for the command
			case $command in
				submit)
					options="--define"
					;;
				sync)
					options="--dry-run -c --download"
					;;
			esac
			options="$options --help"
			COMPREPLY=( $( compgen -W "$options" -- $cur ) )
		else
			case $command in
				help)
					_mgarepo_actions
					return 0
					;;
				import)
					_filedir 'src.rpm'
					return 0
					;;
				upload)
					_filedir 'tar.gz|tar.bz2|tar.lzma|tar.xz|zip'
					return 0
					;;
				del)
					_filedir 'tar.gz|tar.bz2|tar.lzma|tar.xz|zip'
					return 0
					;;
				@(sync|commit|ci))
					_filedir -d
					return 0
					;;
			esac
		fi
	fi

}
complete -F _mgarepo $filenames mgarepo