summaryrefslogtreecommitdiffstats
path: root/src/fedpkg.bash
blob: 8f698e8f39b803ce672cdffd2db28e72bfcfb9f2 (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
# fedpkg bash completion

have fedpkg &&
_fedpkg()
{
    local cur prev commands options command

    COMPREPLY=()
    _get_comp_words_by_ref cur prev

    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
            COMPREPLY=( $( compgen -W '-h --help -u --user --path -v -q' \
            -- "$cur" ) )
        else
            COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
        fi
    else
        case $prev in
            --path|--file|-F|--outdir)
                _filedir
                return 0;
                ;;
            --arch|--arches)
                COMPREPLY=( $( compgen -W 'i386 i586 i686 x86_64' -- "$cur" ) )
                return 0;
                ;;
             --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
            # 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'
                    ;;
                clog|gimmespec|lint|mockbuild|new|giturl|push|tag-request|\
                unused-patches|update|verrel)
                    options='-h'
                    ;;
            esac
            options="$options --help -h"

            COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
        else
            case $command in
                upload)
                    _filedir
                    ;;
                import)
                    COMPREPLY=( ${COMPREPLY[@]:-} \
                        $( compgen -W '$( command ls *.src.rpm 2>/dev/null )' \
                        -- "$cur" ) )
                    ;;
                # no further args required
                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