zsh-workers
 help / color / mirror / code / Atom feed
From: doron.behar@gmail.com
To: zsh-workers@zsh.org
Subject: [PATCH 22/25] Use +functions[] for all helpers.
Date: Sat, 26 May 2018 18:06:31 +0300	[thread overview]
Message-ID: <20180526150634.15683-23-doron.behar@gmail.com> (raw)
In-Reply-To: <20180526150634.15683-1-doron.behar@gmail.com>

From: Doron Behar <doron.behar@gmail.com>

---
 Completion/Unix/Command/_luarocks | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks
index 1dda38cad..cb42d1b36 100644
--- a/Completion/Unix/Command/_luarocks
+++ b/Completion/Unix/Command/_luarocks
@@ -1,6 +1,7 @@
 #compdef luarocks
 
 # {{{ helper: luarocks commands
+(( $+functions[__luarocks_command] )) ||
 __luarocks_command(){
   local -a commands=(
     build:'Build/compile a rock'
@@ -28,6 +29,7 @@ __luarocks_command(){
 # }}}
 # {{{ helper: dependencies mode
 local option_deps_mode='--deps-mode=[How to handle dependencies]:MODE:__luarocks_deps_mode'
+(( $+functions[__luarocks_deps_mode] )) ||
 __luarocks_deps_mode(){
   local modes=(
     'all:use all trees from the rocks_trees list for finding dependencies'
@@ -39,6 +41,7 @@ __luarocks_deps_mode(){
 }
 # }}}
 # {{{ helper: versions of an external rock or nothing for rockspec file
+(( $+functions[__luarocks_rock_version] )) ||
 __luarocks_rock_version(){
   local i=2
   while [[ -n "${words[$i]}" ]]; do
@@ -76,11 +79,13 @@ __luarocks_rock_version(){
 }
 # }}}
 # {{{ helper: lua versions
+(( $+functions[__luarocks_lua_versions] )) ||
 __luarocks_lua_versions(){
   _values -s , 5.3 5.2 5.1
 }
 # }}}
 # {{{ helper: installed rocks cache policy
+(( $+functions[___luarocks_installed_rocks_cache_policy] )) ||
 ___luarocks_installed_rocks_cache_policy(){
   # TODO enable the user to configure manifests file that will be checked here with zstyle
   # the number of seconds since 1970-01-01 the manifest file was modified
@@ -100,6 +105,7 @@ ___luarocks_installed_rocks_cache_policy(){
 }
 # }}}
 # {{{ helper: installed rocks
+(( $+functions[__luarocks_installed_rocks] )) ||
 __luarocks_installed_rocks(){
   local update_policy
   zstyle -s ":completion:${curcontext}:" cache-policy update_policy
@@ -160,6 +166,7 @@ __luarocks_installed_rocks(){
 # - .rockspec file
 # - .src.rock file
 # - external rock
+(( $+functions[__luarocks_rock] )) ||
 __luarocks_rock(){
   local -a alts=()
   for arg in "$@"; do
@@ -182,6 +189,7 @@ __luarocks_rock(){
 }
 # }}}
 # {{{ helper: git tags
+(( $+functions[__luarocks_git_tags] )) ||
 __luarocks_git_tags(){
   autoload +X _git
   local _git_def="$(whence -v _git)"
@@ -207,6 +215,7 @@ local build_command_options=(
   '--only-deps[Installs only the dependencies of the rock]'
   $option_deps_mode
 )
+(( $+functions[_luarocks_build] )) ||
 _luarocks_build(){
   _arguments -A "-*" \
     "${build_command_options[@]}" \
@@ -225,6 +234,7 @@ local config_command_options=(
   '--user-config[Location of the user config file]'
   '--rock-trees[Rocks trees in useFirst the user tree, then the system tree]'
 )
+(( $+functions[_luarocks_config] )) ||
 _luarocks_config(){
   _arguments "${config_command_options[@]}"
 }
@@ -236,6 +246,7 @@ local doc_command_options=(
   '--home[Open the home page of project]'
   '--list[List documentation files only]'
 )
+(( $+functions[_luarocks_doc] )) ||
 _luarocks_doc(){
   _arguments \
     "${doc_command_options[@]}" \
@@ -251,6 +262,7 @@ local download_command_options=(
   '--rockspec[Download .rockspec if available]'
   '--arch=[Download rock for a specific architecture]:ARCH:'
 )
+(( $+functions[_luarocks_download] )) ||
 _luarocks_download(){
   _arguments -A "-*" \
     "${download_command_options[@]}" \
@@ -261,6 +273,7 @@ _luarocks_download(){
 # {{{ `help` command
 # arguments:
 # must: luarocks sub command
+(( $+functions[_luarocks_help] )) ||
 _luarocks_help(){
   _arguments '1: :__luarocks_command'
 }
@@ -270,6 +283,7 @@ _luarocks_help(){
 # - must: .rockspec file / external rock
 # - optional: version
 # NOTE: it receives the same argument as the build command and it accepts the same options as well
+(( $+functions[_luarocks_install] )) ||
 _luarocks_install(){
   _luarocks_build
 }
@@ -277,6 +291,7 @@ _luarocks_install(){
 # {{{ `lint` command
 # arguments:
 # - must: rockspec file (first and last)
+(( $+functions[_luarocks_lint] )) ||
 _luarocks_lint(){
   _arguments '1::{__luarocks_rock "rockspec"}'
 }
@@ -287,6 +302,7 @@ local list_command_options=(
   '--outdated[List only rocks for which there is a higher version available in the rocks server]'
   '--porcelain[Produce machine-friendly output]'
 )
+(( $+functions[_luarocks_list] )) ||
 _luarocks_list(){
   _arguments "${list_command_options[@]}"
 }
@@ -295,6 +311,7 @@ _luarocks_list(){
 # arguments:
 # - optional: rockspec file
 # NOTE: it's options were already described above.
+(( $+functions[_luarocks_make] )) ||
 _luarocks_make(){
   _arguments '1:: :{__luarocks_rock "rockspec"}'
 }
@@ -307,6 +324,7 @@ _luarocks_make(){
 local new_version_command_options=(
   '--tag=[if no version is specified, this option'"'"'s argument is used instead]:TAG:__luarocks_git_tags'
 )
+(( $+functions[_luarocks_new_version] )) ||
 _luarocks_new_version(){
   _arguments -A "-*" \
     "${new_version_command_options[@]}" \
@@ -319,6 +337,7 @@ _luarocks_new_version(){
 # arguments:
 # - must: .rockspec file / external rock
 # - optional: version
+(( $+functions[_luarocks_pack] )) ||
 _luarocks_pack(){
   _luarocks_build
 }
@@ -332,6 +351,7 @@ local path_command_options=(
   '--lr-cpath[Exports the Lua cpath (not formatted as shell command)]'
   '--lr-bin[Exports the system path (not formatted as shell command)]'
 )
+(( $+functions[_luarocks_path] )) ||
 _luarocks_path(){
   _arguments "${path_command_options[@]}"
 }
@@ -344,6 +364,7 @@ local purge_command_options=(
   '--old-versions[Keep the highest-numbered version of each rock and remove the other ones]'
   $option_force
 )
+(( $+functions[_luarocks_purge] )) ||
 _luarocks_purge(){
   _arguments "${purge_command_options[@]}"
 }
@@ -358,6 +379,7 @@ local remove_command_options=(
   $option_force
   $option_force_fast
 )
+(( $+functions[_luarocks_remove] )) ||
 _luarocks_remove(){
   _arguments -A "-*" \
     "${remove_command_options[@]}" \
@@ -373,6 +395,7 @@ local search_command_options=(
   '--binary[Return only pure Lua and binary rocks (rocks that can be used with the "install" command without requiring a C toolchain)]'
   '--all[List all contents of the server that are suitable to this platform, do not filter by name]'
 )
+(( $+functions[_luarocks_search] )) ||
 _luarocks_search(){
   _arguments \
     "${search_command_options[@]}" \
@@ -391,6 +414,7 @@ local show_command_options=(
   '--rock-tree[local tree where rock is installed]'
   '--rock-dir[data directory of the installed rock]'
 )
+(( $+functions[_luarocks_show] )) ||
 _luarocks_show(){
   _arguments \
     "${show_command_options[@]}" \
@@ -404,6 +428,7 @@ _luarocks_show(){
 local unpack_command_options=(
   '--force[Unpack files even if the output directory already exists]'
 )
+(( $+functions[_luarocks_unpack] )) ||
 _luarocks_unpack(){
   _arguments \
     "${unpack_command_options[@]}" \
@@ -418,6 +443,7 @@ local upload_command_options=(
   '--api-key=[Give it an API key]:KEY:{_message "api key"}'
   '--force[Replace existing rockspec if the same revision of a module already exists]'
 )
+(( $+functions[_luarocks_upload] )) ||
 _luarocks_upload(){
   _arguments \
     "${upload_command_options[@]}" \
@@ -441,6 +467,7 @@ local write_rockspec_command_options=(
   '--tag=[Tag to use. Will attempt to extract version number from it]:TAG:__git_tag'
   '--lib=[A comma-separated list of libraries that C files need to link to]:'
 )
+(( $+functions[_luarocks_write_rockspec] )) ||
 _luarocks_write_rockspec(){
   _arguments -A "-*" \
     "${write_rockspec_command_options[@]}" \
-- 
2.17.0


  parent reply	other threads:[~2018-05-26 15:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 15:06 [PATCH 00/25] *** Add completion for luarocks *** doron.behar
2018-05-26 15:06 ` [PATCH 01/25] Add variables for all commands and options doron.behar
2018-05-26 15:06 ` [PATCH 02/25] Remove architecture related option completion doron.behar
2018-05-26 15:06 ` [PATCH 03/25] Add marker style comments doron.behar
2018-05-26 15:06 ` [PATCH 04/25] Remove variables and use their contents directly doron.behar
2018-05-26 15:06 ` [PATCH 05/25] Add curcontext case for every subcommand doron.behar
2018-05-26 15:06 ` [PATCH 06/25] Use better naming scheme for common helpers doron.behar
2018-05-26 15:06 ` [PATCH 07/25] Write better sub commands comments doron.behar
2018-05-26 15:06 ` [PATCH 08/25] Add helpers section doron.behar
2018-05-26 15:06 ` [PATCH 09/25] Make *all* helpers functions begin with __luarocks doron.behar
2018-05-26 15:06 ` [PATCH 10/25] Write all simple sub commands completions doron.behar
2018-05-26 15:06 ` [PATCH 11/25] General internal conventions sync doron.behar
2018-05-26 15:06 ` [PATCH 12/25] Finish helper `__luarocks_lua_versions` doron.behar
2018-05-26 15:06 ` [PATCH 13/25] General cleanup doron.behar
2018-05-26 15:06 ` [PATCH 14/25] Finish `_luarocks_doc` and `_luarocks_config` doron.behar
2018-05-26 15:06 ` [PATCH 15/25] Expand __luarocks_rock_version so it accpets args doron.behar
2018-05-26 15:06 ` [PATCH 16/25] Finish completions for purge and new_version doron.behar
2018-05-26 15:06 ` [PATCH 17/25] Write a better comment for last TODO doron.behar
2018-05-26 15:06 ` [PATCH 18/25] Make cache policy function safer doron.behar
2018-05-26 15:06 ` [PATCH 19/25] Fix git tag completion by autoloading _git doron.behar
2018-05-26 15:06 ` [PATCH 20/25] Use a generic sub command completer doron.behar
2018-05-26 15:06 ` [PATCH 21/25] Use 2 spaces instead of tabs doron.behar
2018-05-26 15:06 ` doron.behar [this message]
2018-05-26 15:06 ` [PATCH 23/25] Improve `___luarocks_installed_rocks_cache_policy` doron.behar
2018-05-26 15:06 ` [PATCH 24/25] Consider `--tree` when searching installed rocks doron.behar
2018-05-26 15:06 ` [PATCH 25/25] Consider `--tree` in versions completion doron.behar
2018-05-26 15:37 ` [PATCH 00/25] *** Add completion for luarocks *** Eitan Adler
2018-05-26 16:09   ` Doron Behar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180526150634.15683-23-doron.behar@gmail.com \
    --to=doron.behar@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).