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

[PATCH 15/25] Expand __luarocks_rock_version so it accpets args.



From: Doron Behar <doron.behar@xxxxxxxxx>

Write `_luarocks_write_rockspec`.
---
 Completion/Unix/Command/_luarocks | 46 +++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks
index aec6ba815..db27a76d5 100644
--- a/Completion/Unix/Command/_luarocks
+++ b/Completion/Unix/Command/_luarocks
@@ -40,11 +40,36 @@ __luarocks_deps_mode(){
 # }}}
 # {{{ helper: versions of an external rock or nothing for rockspec file
 __luarocks_rock_version(){
-	for i in {2..${#build_command_options[@]}}; do
-		if [[ ! -z "${words[$i]}" && ! "${words[$i]}" =~ '^-' && ! -f "${words[$i]}" ]]; then
-			_message -e "version for rock ${words[$i]}"
-			return
+	local i=2
+	while [[ -n "${words[$i]}" ]]; do
+		if [[ ! "${words[$i]}" =~ '^-' ]]; then
+			case "$1" in
+				"external_or_local")
+					if [[ ! -f "${words[$i]}" ]]; then
+						_message -e "version for external rock ${words[$i]}"
+						return
+					else
+						_message -e "version for local rock ${words[$i]}"
+					fi
+					;;
+				"installed")
+					# TODO: actually complete versions of installed rocks using the cache
+					_message -e "version for installed rock ${words[$i]}"
+					return
+					;;
+				"new_version")
+					if [[ -f "${words[$i]}" ]]; then
+						_message -e "new version for rock ${words[$i]}"
+						return
+					fi
+					;;
+				"new_rock")
+					_message -e "version for new rock ${words[$i]}"
+					return
+					;;
+			esac
 		fi
+		i=$(( i + 1 ))
 	done
 }
 # }}}
@@ -170,7 +195,7 @@ _luarocks_build(){
 	_arguments -A "-*" \
 		"${build_command_options[@]}" \
 		'1: :{__luarocks_rock "rockspec" "external"}' \
-		'2:: :__luarocks_rock_version'
+		'2:: :{__luarocks_rock_version "external_or_local"}'
 }
 # }}}
 # {{{ `config` command
@@ -214,7 +239,7 @@ _luarocks_download(){
 	_arguments -A "-*" \
 		"${download_command_options[@]}" \
 		'1: :{__luarocks_rock "external"}' \
-		'2:: :__luarocks_rock_version'
+		'2:: :{__luarocks_rock_version "external_or_local"}'
 }
 # }}}
 # {{{ `help` command
@@ -315,7 +340,7 @@ _luarocks_remove(){
 	_arguments -A "-*" \
 		"${remove_command_options[@]}" \
 		'1: :{__luarocks_rock "installed"}' \
-		'2:: :__luarocks_rock_version'
+		'2:: :{__luarocks_rock_version "installed"}'
 }
 # }}}
 # {{{ `search` command
@@ -388,13 +413,18 @@ local write_rockspec_command_options=(
 	'--license=[A license string, ]:LICENSE:{_message -e "write a license string such as "MIT/X11" or "GNU GPL v3"}'
 	'--summary=[A short one-line description summary]:SUMMARY_TEXT:{_message -e "write a short summary of the rock"}'
 	'--detailed=[A longer description string]:DETAILED_TEXT:{_message -e "write a detailed description of the rock"}'
-	'--homepage=[Project homepage]:URL:_luarocks_write_rockspec_homepage'
+	'--homepage=[Project homepage]:URL:_urls'
 	'--lua-version=[Supported Lua versions]:LUA_VER:__luarocks_lua_versions'
 	'--rockspec-format=[Rockspec format version, such as "1.0" or "1.1"]:VER: '
 	'--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(){
+	_arguments -A "-*" \
+		"${write_rockspec_command_options[@]}" \
+		'1:: :{_message "new rock name"}' \
+		'2:: :{__luarocks_rock_version "new_rock"}' \
+		'3:: :_urls'
 }
 # }}}
 
-- 
2.17.0



Messages sorted by: Reverse Date, Date, Thread, Author