From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6736 invoked by alias); 14 Mar 2012 08:53:58 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16877 Received: (qmail 26548 invoked from network); 14 Mar 2012 08:53:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.161.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=NdH885MNSvC7vRHthLlEWqpdlIt5EVLUBehk8sM7GFY=; b=X7DLHnMb1U2PihOlttXwcHyE7emqdP4D6MCYxYGat+JkUYtnKQP+l9sr0rDJQWd8MQ 4fkPc5eLfyXCEbHyHo0CY5lpdKff2Ap1YLSXJVp+4nOi2SOmw6BHVgsq9JwwsDDKDv99 +XLgCDyx7xqcjUsh21WHlq/pjmDdc/NU73iBgy4rG9/3ck8Qw69EMAnb7CSN1STB7MSa Yogyv6i7F0Mduf8uSYYb4iWzXKIgePJyqwvBgsNbCD0qu3FeAG2MK0XKc/CeSn6NW5V/ 9cbavf6sdV0G0CnqUKNipS9BXzd3j2iNhhcN4hvf6A/QcH+oqNbsCUzFpWsW22PbR5a9 kydw== MIME-Version: 1.0 Date: Wed, 14 Mar 2012 09:53:46 +0100 Message-ID: Subject: Putting options after tasks From: =?ISO-8859-1?Q?Jesper_Nyg=E5rds?= To: zsh-users@zsh.org Content-Type: text/plain; charset=ISO-8859-1 I am trying to write a completion function for gradle, and face some problems regarding the order of options and tasks. Below I have simplified my approach as much as possible, in order to explain my problem clearly. The basis for this is originally the gradle completion from oh-my-zsh. gradle can take any number of options (long options starting with "--") and tasks (with no prefix). In my example below, I have boiled this down to two options ("--info" and "--stacktrace"), and two tasks ("build" and "clean"). These options and tasks can come in any order, so the following command lines would all be valid: gradle clean build gradle --info clean build --stacktrace gradle --stacktrace --info clean build etc My problem is this: the completion below works fine and completes both options and tasks, but once I have at least one task on the command line, it no longer completes for options. So, for example, if I have "gradle build --i" and press , I get no suggestions, whereas "gradle bu" gives "gradle build", and "gradle --i" gives "gradle --info". What do I have to do to make it possible to complete options after tasks? _gradle() { local ret=1 state local curcontext="$curcontext" _arguments -C \ '--info[Log at the info level]' \ '--stacktrace[Display stacktrace on error]' \ '*::command:->command' \ && ret=0 if [[ -n $state ]]; then commands=( "clean:Clean the project" "build:Build the project" ) _describe -t commands 'gradle commands' commands && ret=0 fi return $ret } compdef _gradle gradle