]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - shell/bash-completion.sh
pexpect needs explicit encoding when run under python3
[projects/pld-ftp-admin.git] / shell / bash-completion.sh
CommitLineData
6df3847c
ER
1# various completions for pld-ftp-admin tools
2# Author: Elan Ruusamäe <glen@pld-linux.org>
3
4# return list of pld ftp trees
63b9ab4d 5_pfa_tree() {
6df3847c 6 local cur="$1"
63b9ab4d 7 if [ -z "$PFA_TREES" ]; then
6df3847c
ER
8 local d
9 local -a trees
10 for d in ~/ftp/*/; do
11 d=${d%/}
12 d=${d##*/}
63b9ab4d 13 PFA_TREES+=" $d"
6df3847c
ER
14 done
15 # kill leading space
63b9ab4d 16 PFA_TREES=${PFA_TREES# }
6df3847c
ER
17 fi
18
63b9ab4d 19 COMPREPLY=( $( compgen -W "$PFA_TREES" -- "$cur" ) )
6df3847c
ER
20}
21
22# return list of files in a tree
63b9ab4d 23_pfa_tree_files() {
2b0efd1e 24 local tree="$1" cur="$2" file i
6df3847c
ER
25 local dir=~/ftp/$tree/SRPMS/.metadata
26
27 # generate reply from dir
28 COMPREPLY=( $( compgen -f -X "*.(src.rpm.info)" -- "$dir/$cur" ) )
29 # filter out dirname from results
30 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
31 file=${COMPREPLY[$i]##*/}
32 COMPREPLY[$i]=$file
33 done
34}
35
63610b78 36have pfa-genindex &&
63b9ab4d 37_pfa-genindex()
6df3847c
ER
38{
39 local cur
40
41 COMPREPLY=()
42 _get_comp_words_by_ref cur
43
44 if [[ "$cur" == -* ]]; then
45 COMPREPLY=( $( compgen -W '\
46 -q --quiet --index \
47 --nopoldek --noyum --norpmrepo \
48 --poldek --yum --rpmrepo \
49 ' \
50 -- "$cur" ) )
51 else
63b9ab4d 52 _pfa_tree "$cur"
6df3847c
ER
53 fi
54} &&
63b9ab4d 55complete -F _pfa-genindex pfa-genindex
6df3847c 56
63610b78 57have pfa-lintpkg &&
63b9ab4d 58_pfa-lintpkg()
63610b78
ER
59{
60 local cur arg
61
62 COMPREPLY=()
63 _get_comp_words_by_ref cur
64
65 if [[ "$cur" == -* ]]; then
66 COMPREPLY=( $( compgen -W '-q -s --quiet' -- "$cur" ) )
67 else
68 # The first argument is an tree; the rest are files in a dir
69 _count_args :
70
71 if [[ $args == 1 ]]; then
72 _pfa_tree "$cur"
73 else
74 _get_first_arg
75 _pfa_tree_files "$arg" "$cur"
76 fi
77 fi
78} &&
79complete -F _pfa-lintpkg pfa-lintpkg
80
81have pfa-signpkg &&
82_pfa-signpkg()
6df3847c
ER
83{
84 local cur
85
86 COMPREPLY=()
87 _get_comp_words_by_ref cur
88
89 # The first argument is an tree; the rest are files in a dir
90 _count_args :
91
92 if [[ $args == 1 ]]; then
63b9ab4d 93 _pfa_tree "$cur"
6df3847c 94 else
63b9ab4d 95 _pfa_tree_files "${COMP_WORDS[1]}" "$cur"
6df3847c
ER
96 fi
97} &&
63610b78 98complete -F _pfa-signpkg pfa-signpkg pfa-rmpkg
6df3847c 99
63610b78 100have pfa-mvpkg &&
63b9ab4d 101_pfa-mvpkg()
6df3847c
ER
102{
103 local cur
104
105 COMPREPLY=()
106 _get_comp_words_by_ref cur
107
108 # The first two arguments are tree names; the rest are files in a dir
109 _count_args :
110
111 if [[ $args == 1 ]] || [[ $args == 2 ]]; then
63b9ab4d 112 _pfa_tree "$cur"
6df3847c 113 else
63b9ab4d 114 _pfa_tree_files "${COMP_WORDS[1]}" "$cur"
6df3847c
ER
115 fi
116} &&
63b9ab4d 117complete -F _pfa-mvpkg pfa-mvpkg pfa-testmvpkg
6df3847c
ER
118
119# Local variables:
120# mode: shell-script
121# sh-basic-offset: 4
122# sh-indent-comment: t
123# indent-tabs-mode: nil
124# End:
125# ex: ts=4 sw=4 et filetype=sh
This page took 0.367172 seconds and 4 git commands to generate.