From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13804 invoked by alias); 5 Feb 2014 12:01:12 -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: 18396 Received: (qmail 16407 invoked from network); 5 Feb 2014 12:01:06 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=n6U6k8IMc/fn81VZ5FB8ZHL9ULSz0tKgH0HtvBb1+ek=; b=QB8qw8GgolycJLV8rOvCuecVmLSTxkf/+bQscMNldhSYjXlllk0VHHGCqcwRh1lgdP uxKsWV8JTf7WJLr1BlA/AeziNRKQ23pRpckO8jZLyQxSphzpHUV2/Pe2yaKLiqy4PAtR Vhy/wzmjwm5metpVV7Pweu034DlhZWcV375YW1JzV0GtJ9slBHCzxesQvlp0Ig+rZLHZ noeU/V1oiOxFBlBphBxz9qYxwozI6pAQjlMd5Z0IYd+DYyAdFm3/7uhh8DKe1zZg5fd9 6vwNnRVBIizQHrIWwOcFBvoFYTrqWj3P+EywJhsm7Ubc+/ORkI10j/YJlfezOiy+BgjX oy7w== X-Received: by 10.15.36.70 with SMTP id h46mr1522868eev.96.1391601662936; Wed, 05 Feb 2014 04:01:02 -0800 (PST) Date: Wed, 5 Feb 2014 13:00:58 +0100 From: luc To: zsh-users@zsh.org Subject: completion function for system_profiler (OS X) Message-ID: <20140205120058.GA85309@mbp.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello list menbers, I'm writing a completion function for the OS X command system_profiler. (I did't find one preinstalled with `find $fpath -name _system_profiler` so I assume there isn't one already) The manpage for system_profiler says: > SYNOPSIS > system_profiler [-usage] > system_profiler [-listDataTypes] > system_profiler [-xml] dataType1 ... dataTypeN > system_profiler [-xml] [-detailLevel level] My problem is the third posibility: I do not know how to tell the completion system to allow several dataTypes after the command. I store the dataTypes in an array which I populate with `system_profiler -listDataTypes`. How can I tell zsh that any of these strings may follow in any order several times, unless -usage or -listDataTypes is given? My code so far is attached. Note that the man page is not correct at one point: It is possible to specify both -detailLevel and some dataTypes. For example `system_profiler -detailLevel mini SPAirPortDataType` differs from `system_profiler -detailLevel full SPAirPortDataType` Thank you for any help or hints Lucas --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=_system_profiler #compdef system_profiler typeset -A opt_args local context state line local -a _data_types # TODO: Should this be static? Calling `system_profiler -listDataTypes` takes # about 0.07-0.08 sec. Does this list ever change (between different versions # of OS X)? _data_types=$(_call_program path system_profiler -listDataTypes 2>/dev/null) _arguments \ '(-listDataTypes -detailLevel -timeout -usage)-usage' \ '(-listDataTypes -usage)-xml[generate xml output]' \ '(-listDataTypes -xml -detailLevel -timeout -usage)-listDataTypes[lists the available datatypes]' \ '(-listDataTypes -usage)-detailLevel[level of detail for the report]:detail level:(mini basic full)' \ '(-listDataTypes -usage)-timeout+[maximum time to wait in seconds]' \ && return 0 --nFreZHaLTZJo0R7j--