forked from zsh-users/zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_pip
120 lines (105 loc) · 3.62 KB
/
_pip
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
#compdef pip
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for pip (http://pypi.python.org/pypi/pip).
#
# Source: https://github.com/technolize/zsh-completion-funcs
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * technolize (https://github.com/technolize)
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
local ret=1 state
local -a common_ops
common_ops=(
"--version[display version number]"
{-h,--help}"[show help]"
{-E,--environment=}"[virtualenv environment to run pip]:environment:_directories"
{-s,--enable-site-packages}"[include site-packages in virtualenv]"
{-v,--verbose}"[give more output]"
{-q,--quiet}"[give less output]"
"--log=[log file where a complete record will be kept]"
"--proxy=[specify a proxy in the form user:[email protected]:port]:proxy"
"--timeout=[set the socket timeout (default 15 seconds)]:second"
)
_directories () {
_wanted directories expl directory _path_files -/ "$@" -
}
typeset -A opt_args
_arguments \
':subcommand:->subcommand' \
$common_ops \
'*::options:->options' && ret=0
case $state in
subcommand)
local -a subcommands
subcommands=(
"bundle:create pybundle"
"freeze:put all currently installed packages"
"help:show available commands"
"install:install packages"
"search:search pypi"
"uninstall:uninstall packages"
"unzip:unzip undividual packages"
"zip:zip dividual packages"
)
_describe -t subcommands 'pip subcommand' subcommands && ret=0
;;
options)
local -a args
args=(
$common_ops
)
local -a requirement
requirement=(
{-r,--requirement=}"[install all the packages listed in the given requirements file]:filename:_files"
)
local -a findlink
findlink=(
{-f,--find-links=}"[URL to look for packages at]:url"
)
case $words[1] in
bundle | install)
args+=(
{-e,--editable=}"[install a package directly from a checkout]:VCS+REPOS_URL[@REV]#egg=PACKAGE"
$requirement
$findlink
{-i,--index-url=,--pypi-url=}"[base URL of Python Package Index]:URL"
"--extra-index-url=[extra URLs of package indexes to use]:URL"
{-b,--build=,--build-dir=}"[unpack packages into DIR]:directory:_directories"
{--src=,--source=}"[check out --editable packages into DIR]:directory:_directories"
{-U,--upgrade}"[upgrade all packages to the newest available version]"
{-I,--ignore-installed}"[ignore the installed packages]"
"--noinstall[download and unpack all packages, but don't actually install them]"
"--install-option=[extra arguments to be supplied to the setup.py install command]"
)
;;
freeze)
args+=(
$requirement
$findlink
)
;;
unzip | zip)
args+=(
"--unzip[unzip a package]"
"--no-pyc[do not include .pyc files in zip files]"
{-l,--list}"[list the packages available, and their zip status]"
"--sort-files[with --list, sort packages according to how many files they contain]"
"--path=[restrict operation to the given paths]:paths"
{-n,--simulate}"[do not actually perform the zip/unzip operation]"
)
;;
esac
_arguments $args && ret=0
;;
esac
return ret