]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/pip/_pip
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / pip / _pip
1 #compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4
2 #autoload
3
4 # pip zsh completion, based on last stable release (pip8)
5 # homebrew completion and backwards compatibility
6
7 _pip_all() {
8   # we cache the list of packages (originally from the macports plugin)
9   if (( ! $+piplist )); then
10       zsh-pip-cache-packages
11       piplist=($(cat $ZSH_PIP_CACHE_FILE))
12   fi
13 }
14
15 _pip_installed() {
16   installed_pkgs=($($service freeze | cut -d '=' -f 1))
17 }
18
19 local -a _1st_arguments
20 _1st_arguments=(
21   'install:install packages'
22   'download:download packages'
23   'uninstall:uninstall packages'
24   'freeze:output all currently installed packages (exact versions) to stdout'
25   'list:list installed packages'
26   'show:show information about installed packages'
27   'search:search PyPI'
28   'wheel:build individual wheel archives for your requirements and dependencies'
29   'hash:compute a hash of a local package archive'
30   'help:show available commands'
31   'bundle:create pybundles (archives containing multiple packages)(deprecated)'
32   'unzip:unzip individual packages(deprecated)'
33   'zip:zip individual packages(deprecated)'
34 )
35
36 local expl
37 local -a all_pkgs installed_pkgs
38
39 _arguments \
40   '(-h --help)'{-h,--help}'[show help]' \
41   '(--isolated)--isolated[run pip in isolated mode, ignores environment variables and user configuration]' \
42   '(-v --verbose)'{-v,--verbose}'[give more output]' \
43   '(-V --version)'{-V,--version}'[show version number of program and exit]' \
44   '(-q --quiet)'{-q,--quiet}'[give less output]' \
45   '(--log)--log[log file location]' \
46   '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
47   '(--retries)--retries[max number of retries per connection (default 5 times)]' \
48   '(--timeout)--timeout[socket timeout (default 15s)]' \
49   '(--exists-action)--exists-action[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]' \
50   '(--trusted-host)--trusted-host[mark this host as trusted]' \
51   '(--cert)--cert[path to alternate CA bundle]' \
52   '(--client-cert)--client-cert[path to SSL client certificate]' \
53   '(--cache-dir)--cache-dir[store the cache data in specified directory]' \
54   '(--no-cache-dir)--no-cache-dir[disable de cache]' \
55   '(--disable-pip-version-check)--disable-pip-version-check[do not check periodically for new pip version downloads]' \
56   '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in (deprecated)]' \
57   '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv (deprecated)]' \
58   '*:: :->subcmds' && return 0
59
60 if (( CURRENT == 1 )); then
61   _describe -t commands "pip subcommand" _1st_arguments
62   return
63 fi
64
65 case "$words[1]" in
66   search)
67     _arguments \
68       '(--index)--index[base URL of Python Package Index]' ;;
69   freeze)
70     _arguments \
71       '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
72   install)
73     _arguments \
74       '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
75       '(--user)--user[install packages to user home]' \
76       '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
77       '(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \
78       '(--no-deps --no-dependencies)'{--no-deps,--no-dependencies}'[iIgnore package dependencies]' \
79       '(--no-install)--no-install[only download packages]' \
80       '(--no-download)--no-download[only install downloaded packages]' \
81       '(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
82       '(--single-version-externally-managed)--single-version-externally-managed[do not download/install dependencies. requires --record or --root]'\
83       '(--root)--root[treat this path as a fake chroot, installing into it. implies --single-version-externally-managed]'\
84       '(--record)--record[file to record all installed files to.]'\
85       '(-r --requirement)'{-r,--requirement}'[requirements file]: :_files'\
86       '(-e --editable)'{-e,--editable}'[path of or url to source to link to instead of installing.]: :_files -/'\
87       '1: :->packages' &&  return 0
88
89       if [[ "$state" == packages ]]; then
90         _pip_all
91         _wanted piplist expl 'packages' compadd -a piplist
92         _files -g "*.(tar.gz|whl)"
93       fi ;;
94   uninstall)
95     _pip_installed
96     _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
97   show)
98     _pip_installed
99     _wanted installed_pkgs expl 'installed packages' compadd -a installed_pkgs ;;
100 esac