From 18f83e1a3a042d3db53cd60e312df44703225cd8 Mon Sep 17 00:00:00 2001 From: Valentin Haenel Date: Tue, 10 Feb 2015 17:01:21 +0100 Subject: [PATCH] refactoring for reuse --- _conda | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/_conda b/_conda index 3eff66b..cd6c9df 100644 --- a/_conda +++ b/_conda @@ -84,27 +84,29 @@ _arguments -C $opts \ ': :->command' \ '*:: :->subcmd' -install_opts=( +base_opts=( '(-h --help)'{-h,--help}'[show the help message and exit]' \ + '(-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]' \ + '(-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-local[use locally built packages]' \ + ) +install_opts=( '(-y --yes)'{-y,--yes}'[do not ask for confirmation]' \ '--dry-run[only display what would have been done]' \ '(-f --force)'{-f,--force}'[force install]' \ '--file[read package versions from file]:file:_path_files' \ - '--unknown[use index metadata from the local package cache]' \ '--no-deps[do not install dependencies]' \ '(-m --mkdir)'{-m,--mkdir}'[create prefix directory if necessary]' \ - '--use-index-cache[use cache of channel index files]' \ - '--use-local[use locally built packages]' \ '--offline[offline mode, don''t connect to internet]' \ '--no-pin[ignore pinned file]' \ - '(-c --channel)'{-c,--channel}'[additional channel to search for packages]:channel:__conda_channels'\ - '--override-channels [do not search default or .condarc channels]' \ - '(-n --name=)'{-n,--name=}'[install into given conda environment]:environment:__conda_envs' \ - '(-p --prefix)'{-p,--prefix}'[full path to environment prefix]:path:_path_files' \ '(-q --quiet)'{-q,--quiet}'[do not display progress bar]'\ '--copy[Install all packages using copies instead of hard- or soft-linking]' \ '--alt-hint[Use an alternate algorithm to generate an unsatisfiable hint]' \ - '--json[report all output as json.]' \ ) case $state in @@ -114,7 +116,8 @@ case $state in (subcmd) case ${line[1]} in (install) - _arguments -C $install_opts \ + _arguments -C $base_opts \ + $install_opts \ '--revision[revert to the specified revision]:revision' \ '*:packages:__conda_packages_search' \ ;; @@ -130,25 +133,17 @@ case $state in '*:regex:' \ ;; (search) - _arguments -C '(-h --help)'{-h,--help}'[show the help message and exit]' \ - '(-n --name=)'{-n,--name=}'[name of environment]:environment:__conda_envs' \ - '(-p --prefix)'{-p,--prefix}'[full path to environment prefix]:path:_path_files' \ + _arguments -C $base_opts \ '(-c --canonical)'{-c,--canonical}'[output canonical names of packages only]' \ - '--unknown[use index metadata from the local package cache]' \ - '--use-index-cache[use cache of channel index files]' \ - '(-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.]' \ '(-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.]' \ '--spec[Treat regex argument as a package specification]' \ - '--json[report all output as json.]' \ - '--use-local[use locally built packages]' \ '*:regex:' \ ;; (update) - _arguments -C $install_opts \ + _arguments -C $base_opts \ + $install_opts \ '--all[Update all installed packages in the environment]' \ '*:packages:__conda_packages_installed' \ ;;