From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28656 invoked by alias); 26 May 2018 15:07:20 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42835 Received: (qmail 28400 invoked by uid 1010); 26 May 2018 15:07:19 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f48.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.48):SA:0(-1.9/5.0):. Processed in 0.723219 secs); 26 May 2018 15:07:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: doron.behar@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=6uP2yZy2gAnrzaz9jxLtTwzGoT6+mDO0zqpMftMNxes=; b=fpczkjOKGR8lecSKciFgqu5kVQZSy+FxMbKatvH58xvUZ6Qu0cyn0UUcD3zEg/vtp6 BGSX0Le4p70a/HsfslRIqI2elW10QPQCzE5NB5JIKfCKKlkc6rjqCvydsgnsywxBnO8y tK/r+3GC0a0vafNdKgj4EXZh1T8QnJpLsUTMefzyxHmTK44/k2oDkw/dHy5pDoRXZSyQ HVK29XSgN63dmVrHj0QlViu1GTRDqKPY2SKja5vn8BX+oqymBivvbbVwVrgaIwtXo+Oj JabZGXla1mIhBgK1jMabJFq9GZ2eMqL9/zVFDWbsw0ENRhvkUgm4DiE+8j+oMBhShImA /byg== X-Gm-Message-State: ALKqPwdOuuGtP307YPprze+PsRPP6CE+2+Y/OBaHTwuOwB+HY5j04ePA UNO4FogxUU4c2UXAO9JkNnORLzwG X-Google-Smtp-Source: ADUXVKL0ft+yNMQRSVJCcx9LDLD6Zi1OxNk8HHpsf8oMtGoiYYCB+n84eil0+4CI33ZxgE5LcICEGg== X-Received: by 2002:a1c:7151:: with SMTP id m78-v6mr4491378wmc.150.1527347235472; Sat, 26 May 2018 08:07:15 -0700 (PDT) From: doron.behar@gmail.com To: zsh-workers@zsh.org Subject: [PATCH 08/25] Add helpers section. Date: Sat, 26 May 2018 18:06:17 +0300 Message-Id: <20180526150634.15683-9-doron.behar@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180526150634.15683-1-doron.behar@gmail.com> References: <20180526150634.15683-1-doron.behar@gmail.com> From: Doron Behar --- 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