From 8260ef5ae12fef38ab380b75050646810b6f599d Mon Sep 17 00:00:00 2001 From: Valentin Haenel Date: Wed, 11 Feb 2015 13:15:07 +0100 Subject: [PATCH] more refactoring --- _conda | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/_conda b/_conda index 035dd86..89ec057 100644 --- a/_conda +++ b/_conda @@ -88,17 +88,24 @@ help_opts=( '(-h --help)'{-h,--help}'[show the help message and exit]' \ ) +json_opts=( + '--json[report all output as json.]' \ + ) -base_opts=( +env_opts=( '(-n --name=)'{-n,--name=}'[name of environment]:environment:__conda_envs' \ '(-p --prefix)'{-p,--prefix}'[full path to environment prefix]:path:_path_files' \ - '--unknown[use index metadata from the local package cache]' \ - '--use-index-cache[use cache of channel index files]' \ + ) + +channel_opts=( '(-c --channel)'{-c,--channel}'[additional channel to search for packages]:channel:__conda_channels'\ '--override-channels [do not search default or .condarc channels]' \ - '--json[report all output as json.]' \ + '--use-index-cache[use cache of channel index files]' \ '--use-local[use locally built packages]' \ ) + +base_opts=( + ) install_opts=( '(-y --yes)'{-y,--yes}'[do not ask for confirmation]' \ '--dry-run[only display what would have been done]' \ @@ -134,9 +141,8 @@ case $state in ;; (list) _arguments -C $help_opts \ - '(-n --name=)'{-n,--name=}'[install into given conda environment]:environment:__conda_envs' \ - '(-p --prefix)'{-p,--prefix}'[full path to environment prefix]:path:_path_files' \ - '--json[report all output as json.]' \ + $env_opts \ + $json_opts \ '(-c --canonical)'{-c,--canonical}'[output canonical names of packages only]' \ '(-e --export)'{-e,--export}'[output requirement string only]' \ '(-r --revisions)'{-r,--revision}'[list the revision history and exit]' \ @@ -146,7 +152,11 @@ case $state in (search) _arguments -C $help_opts \ $base_opts \ + $env_opts \ + $json_opts \ + $channel_opts \ '(-c --canonical)'{-c,--canonical}'[output canonical names of packages only]' \ + '--unknown[use index metadata from the local package cache]' \ '(-o --outdated)'{-o,--outdated}'[only display installed but outdated packages]' \ '(-v --verbose)'{-v,--verbose}'[Show available packages as blocks of data]' \ '--platform[Search the given platform.]' \ @@ -154,24 +164,41 @@ case $state in '*:regex:' \ ;; (create) - _arguments -C $base_opts \ + _arguments -C $help_opts \ + $base_opts \ + $env_opts \ $install_opts \ + $json_opts \ + $channel_opts \ '--clone[path to (or name of) existing local environment]' \ '--no-default-packages[ignore create_default_packages in condarc file]' \ '*:packages:__conda_packages_search' \ ;; (install) - _arguments -C $base_opts \ + _arguments -C $help_opts \ + $base_opts \ + $env_opts \ $install_opts \ + $json_opts \ + $channel_opts \ '--revision[revert to the specified revision]:revision' \ '*:packages:__conda_packages_search' \ ;; (update) - _arguments -C $base_opts \ + _arguments -C $help_opts \ + $base_opts \ + $env_opts \ $install_opts \ + $json_opts \ + $channel_opts \ '--all[Update all installed packages in the environment]' \ '*:packages:__conda_packages_installed' \ ;; + (remove) + _arguments -C $help_opts \ + $env_opts \ + $json_opts \ + $channel_opts \ (*) #_arguments -C $opts _path_files