author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 29 Mar 2023 23:42:06 +0300 | |
changeset 1018 | 831e2c1bf980 |
parent 729 | 3808bb55f8bb |
permissions | -rw-r--r-- |
728 | 1 |
# -*- mode: sh; sh-shell-file: bash -*- |
2 |
||
3 |
_pip() |
|
4 |
{ |
|
5 |
local _cmds='install uninstall freeze list show search wheel help' |
|
6 |
local _acts='switch ignore wipe backup' |
|
7 |
local _opts='-h --help -v --verbose -V --version -q --quiet --proxy --timeout' |
|
8 |
local _index_opts='-i --index-url --extra-index-url --no-index -f --find-links --allow-external --allow-all-external --allow-unverified --process-dependency-links' |
|
9 |
local _install_opts='-e --editable -U --upgrade --force-reinstall -I --ignore-installed --no-deps --no-install --no-download \ |
|
10 |
--install-option --user --egg --compile --no-compile --no-use-wheel --pre --no-clean \ |
|
11 |
-e --editable -b --build -t --target -d --download --download-cache \ |
|
12 |
-r --requirement' |
|
13 |
local _uninstall_opts='-y --yes -r --requirement' |
|
14 |
local _list_opts='-o --outdated -u --uptodate -e --editable -l --local --pre' |
|
15 |
local _freeze_opts='-f --find-links -l --local' |
|
16 |
local _search_opts='--index' |
|
17 |
local _show_opts='--index' |
|
18 |
local _wheel_opts='--no-use-wheel --build-option --no-deps --global-option --pre --no-clean \ |
|
19 |
-w --wheel-dir --download-cache -b --build |
|
20 |
-r, --requirement' |
|
21 |
local cur |
|
22 |
cur=${COMP_WORDS[COMP_CWORD]} |
|
23 |
if [[ $COMP_CWORD = 1 ]]; then |
|
24 |
COMPREPLY=( $(compgen -W '$_cmds' -- "$cur") ) |
|
25 |
return 0 |
|
26 |
fi |
|
27 |
local first prev |
|
28 |
first=${COMP_WORDS[1]} |
|
29 |
prev=${COMP_WORDS[COMP_CWORD-1]} |
|
30 |
case "$prev" in |
|
31 |
--cert|--log|--log-file) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
32 |
compopt -o default; COMPREPLY=() |
728 | 33 |
return 0 ;; |
34 |
--exists-action) |
|
35 |
COMPREPLY=( $(compgen -W '$_acts' -- "$cur") ) |
|
36 |
return 0 ;; |
|
37 |
esac |
|
38 |
case $first in |
|
39 |
install) |
|
40 |
case $prev in |
|
41 |
-e|--editable|-b|--build|-t|--target|-d|--download|--download-cache) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
42 |
compopt -o dirnames; COMPREPLY=() |
728 | 43 |
return 0 ;; |
44 |
-r|--requirement) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
45 |
compopt -o default; COMPREPLY=() |
728 | 46 |
return 0 ;; |
47 |
esac |
|
48 |
COMPREPLY=( $(compgen -W '$_install_opts $_opts $_index_opts' -- "$cur") ) |
|
49 |
return 0 ;; |
|
50 |
uninstall) |
|
51 |
case $prev in |
|
52 |
-r|--requirement) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
53 |
compopt -o default; COMPREPLY=() |
728 | 54 |
return 0 ;; |
55 |
esac |
|
56 |
COMPREPLY=( $(compgen -W '$_uninstall_opts $_opts' -- "$cur") ) |
|
57 |
return 0 ;; |
|
58 |
list) |
|
59 |
COMPREPLY=( $(compgen -W '$_list_opts $_opts $_index_opts' -- "$cur") ) |
|
60 |
return 0 ;; |
|
61 |
freeze) |
|
62 |
case $prev in |
|
63 |
-r|--requirement) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
64 |
compopt -o default; COMPREPLY=() |
728 | 65 |
return 0 ;; |
66 |
esac |
|
67 |
COMPREPLY=( $(compgen -W '$_freeze_opts $_opts' -- "$cur") ) |
|
68 |
return 0 ;; |
|
69 |
search) |
|
70 |
COMPREPLY=( $(compgen -W '$_search_opts $_opts' -- "$cur") ) |
|
71 |
return 0 ;; |
|
72 |
show) |
|
73 |
COMPREPLY=( $(compgen -W '$_show_opts $_opts' -- "$cur") ) |
|
74 |
return 0 ;; |
|
75 |
wheel) |
|
76 |
case $prev in |
|
77 |
-w|--wheel-dir|--download-cache|-b|--build) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
78 |
compopt -o dirnames; COMPREPLY=() |
728 | 79 |
return 0 ;; |
80 |
-r|--requirement) |
|
729
3808bb55f8bb
Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
728
diff
changeset
|
81 |
compopt -o default; COMPREPLY=() |
728 | 82 |
return 0 ;; |
83 |
esac |
|
84 |
COMPREPLY=( $(compgen -W '$_wheel_opts $_opts $_index_opts' -- "$cur") ) |
|
85 |
return 0 ;; |
|
86 |
esac |
|
87 |
COMPREPLY=( $(compgen -W '$_opts' -- "$cur") ) |
|
88 |
return 0 |
|
89 |
} && |
|
90 |
complete -F _pip pip pip2 pip2.5 pip2.6 pip2.7 pip2.8 |
|
91 |