Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 15/25] Expand __luarocks_rock_version so it accpets args.
- X-seq: zsh-workers 42842
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 15/25] Expand __luarocks_rock_version so it accpets args.
- Date: Sat, 26 May 2018 18:06:24 +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=PW0/UvU3aQeOFJz/YO+pYzSJLWRK6Z/lZCuNMLqPoEw=; b=XYtuyqnl65pTzBa/Hzfm1sH5BRyL5njQNwAiaslAaVClGfUEpiAsEQgGEHrCT8JbFK Eqz9Glt0KDBRwJ5kLmrHK65rTZxXHwskSegLoGlw2z4vhsufStvSOiCuYLftJkz+UuBe IJZosd5+zSPVCmTv9rP5+5LSitReZQxMoLVki0aElEYF6rGClB4Ci/Lzi87l5HuNdq6C +V4yTXK3MeJWj/F8FuZXH3pP0eOXkK1XOQjEZe1h9Kk3r1Svur8EXHfonnzxgwwXnLvO NV6g/qw7mMbdY/uMGp0p7uHoLlM35cYIHJzcFm66JckeEi5w4qLuHQqg+WqT3WElDrvm pgeg==
- 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>
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