blob: 0254233e895d8479195563c048d41bdacffc013c (
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
|
# Bash completion function for qualudis
# Written by Mike Kelly
# vim: set et sw=4 sts=4 ts=4 ft=sh :
# NOTE: This is still a work in progress, don't expect it to work well or
# properly right now.
_qualudis_get_repodir() {
local repodir starting_dir="${1}"
[[ -f ./profiles/repo_name ]] && repodir=$(readlink -f ${starting_dir})
[[ -z "${repodir}" && -f ../profiles/repo_name ]] \
&& repodir=$(readlink -f ${starting_dir}/..)
[[ -z "${repodir}" && -f ../../profiles/repo_name ]] \
&& repodir=$(readlink -f ${starting_dir}/../..)
[[ -z "${repodir}" ]] && return 1
echo "${repodir}"
}
_qualudis() {
local cur prev opts repodir
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
# Figure out what our repository dir is
[[ -d ${cur} ]] && repodir="$(_qualudis_get_repodir "${cur}")"
[[ -z "${repodir}" ]] && repodir="$(_qualudis_get_repodir "$(pwd)")"
opts="--describe -d \
--version -V \
--help -h \
--qa-check -c \
--exclude-qa-check -C \
--archs -a \
--excluded-arches -A \
--verbose -v \
--quiet -q \
--log-level -L \
--message-level -M \
--write-cache-dir \
--master-repository-dir"
case "${cur}" in
-*)
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
return 0
;;
*)
case "${prev}" in
## Enum operators
--log-level|-L)
COMPREPLY=($(compgen -W "debug qa warning silent" -- "${cur}"))
return 0
;;
--message-level|-M)
COMPREPLY=($(compgen -W "info minor major fatal" -- "${cur}"))
return 0
;;
--qa-check|-c|--exclude-qa-check|-C)
COMPREPLY=($(compgen -W "$(qualudis --log-level silent --describe |sed -n 's/^ \(.*\):$/\1/p')" -- "${cur}"))
return 0
;;
--arches|-a|--exclude-arches|-A)
COMPREPLY=($(compgen -W "$(< "${repodir}/profiles/arch.list")" -- "${cur}"))
return 0
;;
*)
_filedir -d
;;
esac
;;
esac
}
complete -o filenames -F _qualudis qualudis
|