Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 08/25] Add helpers section.
- X-seq: zsh-workers 42835
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 08/25] Add helpers section.
- Date: Sat, 26 May 2018 18:06:17 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20161025;        h=from:to:subject:date:message-id:in-reply-to:references;        bh=6uP2yZy2gAnrzaz9jxLtTwzGoT6+mDO0zqpMftMNxes=;        b=uGvf6WZxNmrybXVucyyYuqrx8JdZ/db7cFERFu+q+HPRI9Pplm22IZDUuEMsv9t4oJ         h+im0EBNzN1+R0ttwlLKOq//8jlljOV7aqy+flLcSIFKIcURW1JjbYyovuzBS9ztaf7z         4Jq40XNarih4BOewj3HAFj+tkJ5RRGL2PkAbKT1Mcy5pez66yUQNAkBbjkkGGh0T4Sde         RvH+QQIt5Uqnqmwd5gkam7W3ARV7Ux5fBTfceTckR9rF7EfDMTx2Fcpd1rYxxfbeRRqO         5L90vc3aFNEJCvg0udgrN0yPLrnpqB/TurbIQiSn6WjDAjqhGcB3LuglURtDOEgpKoqx         Ub/Q==
- In-reply-to: <20180526150634.15683-1-doron.behar@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180526150634.15683-1-doron.behar@gmail.com>
From: Doron Behar <doron.behar@xxxxxxxxx>
---
 Completion/Unix/Command/_luarocks | 65 ++++++++++++++++++++++++-------
 1 file changed, 50 insertions(+), 15 deletions(-)
diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks
index b9f6c8af6..acbc16cb4 100644
--- a/Completion/Unix/Command/_luarocks
+++ b/Completion/Unix/Command/_luarocks
@@ -1,5 +1,55 @@
 #compdef luarocks
 
+# {{{ helper: dependencies mode
+local option_deps_mode='--deps-mode=[How to handle dependencies]:MODE:__luarocks_deps_mode'
+__luarocks_deps_mode(){
+	local modes=(
+		'all:use all trees from the rocks_trees list for finding dependencies'
+		'one:use only the current tree (possibly set with --tree)'
+		'order:use trees based on order (use the current tree and all trees below it on the rocks_trees list)'
+		'none:ignore dependencies altogether'
+	)
+	_describe 'dependencies mode' modes
+}
+# }}}
+# {{{ helper: versions of an external rock
+__luarocks_rock_version(){
+	for i in {2..${#build_command_options[@]}}; do
+		if [[ ! -z "${words[$i]}" && ! "${words[$i]}" =~ '^-' && ! -f "${words[$i]}" ]]; then
+			# TODO: complete with optional versions
+			_message -e "version for rock ${words[$i]}"
+			return
+		fi
+	done
+}
+# }}}
+# {{{ helper: list of libraries that C files need to link to
+_luarocks_write_rockspec_lib(){
+}
+# }}}
+# {{{ helper: lua versions
+# TODO
+__luarocks_lua_version(){
+	_values -s , 
+}
+# }}}
+# {{{ helper: rockspec file / rockpack (.src.rock file) / external according to demand
+__luarocks_rock(){
+	local -a arguments=()
+	for arg in "$@"; do
+		case $arg in
+			(file)
+				arguments+=(':rock file:{_files -g "*.rockspec"}')
+				;;
+			(external)
+				arguments+=(':external rock:')
+				;;
+		esac
+	done
+	_alternative ${arguments[@]}
+}
+# }}}
+
 # {{{ `build` command
 # arguments:
 # - must: .rockspec file / external rock
@@ -9,21 +59,11 @@ local make_command_options=(
 	'--keep[Do not remove previously installed versions of the rock after building a new one]'
 	'--branch=[Override the `source.branch` field in the loaded rockspec]:NAME:{_message "branch name"}'
 )
-local option_deps_mode='--deps-mode=[How to handle dependencies. Four modes are supported:MODE:__luarocks_deps_mode'
 local build_command_options=(
 	"${make_command_options[@]}"
 	'--only-deps[Installs only the dependencies of the rock]'
 	$option_deps_mode
 )
-__luarocks_deps_mode(){
-	local modes=(
-		'all:use all trees from the rocks_trees list for finding dependencies'
-		'one:use only the current tree (possibly set with --tree)'
-		'order:use trees based on order (use the current tree and all trees below it on the rocks_trees list)'
-		'none:ignore dependencies altogether'
-	)
-	_describe 'dependencies mode' modes
-}
 _luarocks_build(){
 }
 # }}}
@@ -217,11 +257,6 @@ 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]:_luarocks_write_rockspec_lib'
 )
-_luarocks_write_rockspec_lib(){
-}
-# TODO
-__luarocks_version(){
-	_values -s , 
 _luarocks_write_rockspec(){
 }
 # }}}
-- 
2.17.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author