blob: 1a29d2b63d2053a3624ed5920a912e8d4fa9a6d1 (
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# fedpkg bash completion
have fedpkg &&
_fedpkg()
{
local cur prev commands options command
COMPREPLY=()
_get_comp_words_by_ref cur prev
# define all available commands to complete
commands='help build chain-build clean clog clone co commit ci compile \
diff gimmespec giturl import install lint local mockbuild new new-sources \
patch prep push scratch-build sources srpm switch-branch tag-request \
unused-patches update upload verrel'
if [[ $COMP_CWORD -eq 1 ]] ; then
if [[ "$cur" == -* ]]; then
# show available options when no subcommand is provided
COMPREPLY=( $( compgen -W '-h --help -u --user --path -v -q' \
-- "$cur" ) )
else
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
fi
else
# these completions are available to all commands and are executed
# when a specific parameter is given
case $prev in
# list all files in current directory
--path|--file|-F|--outdir)
_filedir
return 0;
;;
# list available architectures when provided with these parameters
--arch|--arches)
COMPREPLY=( $( compgen -W 'i386 i586 i686 x86_64' -- "$cur" ) )
return 0;
;;
# list all source RPMs in current directory
--srpm)
COMPREPLY=( ${COMPREPLY[@]:-} \
$( compgen -W '$( command ls *.src.rpm 2>/dev/null )' \
-- "$cur" ) )
return 0;
;;
-*)
return 0;
;;
esac
command=${COMP_WORDS[1]}
if [[ "$cur" == -* ]]; then
# list possible options for the command
case $command in
build)
options='--nowait --background --skip-tag --scratch --test'
;;
chain-build)
options='--nowait --background'
;;
clean)
options='--dy-run -n -x'
;;
clone|co)
options='--branches -B --branch -b --anonymous -a'
;;
commit|ci)
options='-m --message -F --file -p --push'
;;
compile)
options='--arch --short-circuit'
;;
import)
options='--branch -b --create -c'
;;
install)
options='--arch --short-circuit'
;;
local)
options='--arch --md5'
;;
patch)
options='--suffix --rediff'
;;
prep)
options='--arch'
;;
scratch-build)
options='--nowait --background --arches --srpm'
;;
sources)
options='--outdir'
;;
srpm)
options='--md5'
;;
switch-branch)
options='-l'
;;
# don't complete by listing files in current directory for
# these commands, just provide the help option
clog|gimmespec|lint|mockbuild|new|giturl|push|tag-request|\
unused-patches|update|verrel)
options='-h --help'
;;
esac
# these options are available to all commands
options="$options --help -h"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
else
# different completion for these commands
case $command in
upload)
_filedir
;;
import)
# complete by listing all source rpms
COMPREPLY=( ${COMPREPLY[@]:-} \
$( compgen -W '$( command ls *.src.rpm 2>/dev/null )' \
-- "$cur" ) )
;;
# no further arguments are required for these commands
help|build|clean|clog|compile|gimmespec|giturl|install|lint|\
local|mockbuild|new|patch|prep|push|scratch-build|sources|\
srpm|switch-branch|tag-request|unused-patches|update|verrel)
;;
*)
_filedir
;;
esac
fi
fi
return 0
} &&
complete -F _fedpkg -o filenames fedpkg
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
|