Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 08/25] Add helpers section.



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