summaryrefslogtreecommitdiffstats
path: root/bash_completion.d/poetry.bash-completion
blob: 19a7e047caba35f3c671ccfc1dceadfb1a4d8ab2 (plain) (blame)
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
_poetry_3a61cd031c563512_complete()
{
    local cur script coms opts com
    COMPREPLY=()
    _get_comp_words_by_ref -n : cur words

    # for an alias, get the real script behind it
    if [[ $(type -t ${words[0]}) == "alias" ]]; then
        script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/")
    else
        script=${words[0]}
    fi

    # lookup for command
    for word in ${words[@]:1}; do
        if [[ $word != -* ]]; then
            com=$word
            break
        fi
    done

    # completing for an option
    if [[ ${cur} == --* ]] ; then
        opts="--ansi --help --no-ansi --no-interaction --quiet --verbose --version"

        case "$com" in

            (about)
            opts="${opts} "
            ;;

            (add)
            opts="${opts} --allow-prereleases --dev --dry-run --extras --lock --optional --platform --python --source"
            ;;

            (build)
            opts="${opts} --format"
            ;;

            (cache)
            opts="${opts} "
            ;;

            (check)
            opts="${opts} "
            ;;

            (config)
            opts="${opts} --list --local --unset"
            ;;

            (debug)
            opts="${opts} "
            ;;

            (env)
            opts="${opts} "
            ;;

            (export)
            opts="${opts} --dev --extras --format --output --with-credentials --without-hashes"
            ;;

            (help)
            opts="${opts} "
            ;;

            (init)
            opts="${opts} --author --dependency --description --dev-dependency --license --name --python"
            ;;

            (install)
            opts="${opts} --dry-run --extras --no-dev --no-root --remove-untracked"
            ;;

            (lock)
            opts="${opts} --no-update"
            ;;

            (new)
            opts="${opts} --name --src"
            ;;

            (publish)
            opts="${opts} --build --cert --client-cert --dry-run --password --repository --username"
            ;;

            (remove)
            opts="${opts} --dev --dry-run"
            ;;

            (run)
            opts="${opts} "
            ;;

            (search)
            opts="${opts} "
            ;;

            (self)
            opts="${opts} "
            ;;

            (shell)
            opts="${opts} "
            ;;

            (show)
            opts="${opts} --all --latest --no-dev --outdated --tree"
            ;;

            (update)
            opts="${opts} --dry-run --lock --no-dev"
            ;;

            (version)
            opts="${opts} --short"
            ;;

        esac

        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
        __ltrim_colon_completions "$cur"

        return 0;
    fi

    # completing for a command
    if [[ $cur == $com ]]; then
        coms="about add build cache check config debug env export help init install lock new publish remove run search self shell show update version"

        COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
        __ltrim_colon_completions "$cur"

        return 0
    fi
}

complete -o default -F _poetry_3a61cd031c563512_complete poetry
complete -o default -F _poetry_3a61cd031c563512_complete /home/lemon/.poetry/bin/poetry