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

[PATCH 05/25] Add curcontext case for every subcommand.



From: Doron Behar <doron.behar@xxxxxxxxx>

Thanks `src/_android`!
---
 Completion/Unix/Command/_luarocks | 74 +++++++++++++++++++++++++++++--
 1 file changed, 70 insertions(+), 4 deletions(-)

diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks
index b14f6a8b3..1b3767b17 100644
--- a/Completion/Unix/Command/_luarocks
+++ b/Completion/Unix/Command/_luarocks
@@ -175,6 +175,7 @@ _luarocks_write_rockspec_lib(){
 # TODO
 _luarocks_version(){
 	_values -s , 
+_luarocks_write_rockspec(){
 }
 # }}}
 
@@ -199,12 +200,12 @@ _luarocks_command(){
 		show:'Show information about an installed rock'
 		unpack:'Unpack the contents of a rock'
 		upload:'Upload a rockspec to the public rocks repository'
-		write_rockspect:'Write a template for a rockspec file'
+		write_rockspec:'Write a template for a rockspec file'
 	)
-	_describe 'command' commands
+	_describe -t commands 'command' commands "$@"
 }
 
-_arguments \
+_arguments -C \
 	'(--server --only-server)--server=[Fetch rocks/rockspecs from this server]:HOST:_hosts' \
 	'(--server --only-server)--only-server=[Fetch rocks/rockspecs from this server only]:HOST:_hosts' \
 	'--only-sources=[Restrict downloads to paths matching the given URL]:URL:_urls' \
@@ -212,5 +213,70 @@ _arguments \
 	'--local[Use the tree in the user'"'"'s home directory]' \
 	'--verbose[Display verbose output of commands executed]' \
 	'--timeout=[Timeout on network operations]:SECONDS:{_message "timeout (seconds)"}' \
-	'*:COMMAND:_luarocks_command'
+	'1: :_luarocks_command' \
+	'*::arg:->args'
 
+case "$state" in
+	(args)
+		curcontext="${curcontext%:*:*}:luarocks_${words[1]}:"
+		case $words[1] in
+			(build)
+				_luarocks_build
+				;;
+			(config)
+				_luarocks_config
+				;;
+			(doc)
+				_luarocks_doc
+				;;
+			(download)
+				_luarocks_download
+				;;
+			(help)
+				_luarocks_help
+				;;
+			(install)
+				_luarocks_install
+				;;
+			(lint)
+				_luarocks_lint
+				;;
+			(list)
+				_luarocks_list
+				;;
+			(make)
+				_luarocks_make
+				;;
+			(new_version)
+				_luarocks_new_version
+				;;
+			(pack)
+				_luarocks_pack
+				;;
+			(path)
+				_luarocks_path
+				;;
+			(purge)
+				_luarocks_purge
+				;;
+			(remove)
+				_luarocks_remove
+				;;
+			(search)
+				_luarocks_search
+				;;
+			(show)
+				_luarocks_show
+				;;
+			(unpack)
+				_luarocks_unpack
+				;;
+			(upload)
+				_luarocks_upload
+				;;
+			(write_rockspec)
+				_luarocks_write_rockspec
+				;;
+		esac
+		;;
+esac
-- 
2.17.0



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