From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26613 invoked by alias); 11 Jul 2016 22:14:00 -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: X-Seq: 38832 Received: (qmail 11529 invoked from network); 11 Jul 2016 22:14:00 -0000 X-Qmail-Scanner-Diagnostics: from nm9-vm2.bullet.mail.ir2.yahoo.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(212.82.96.145):SA:0(0.0/5.0):. Processed in 0.140665 secs); 11 Jul 2016 22:14:00 -0000 X-Spam-Status: No, score=0.0 required=5.0 X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1468274871; bh=kAok7UpBfAtBljXhLGmFmcILU+9srRUDdU063aI/MJQ=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=Lex9oYMPmtBqlpDI+0oD0hXl3TY9+p82qIQ8cvMxCfs9SzLR1h2Pg3/vRilU7itoNtsREeuVuOY9EjA9SNNj5YV+fHlhsQ4V7n9inbq4MCZZBCBLrPGqZ83hSLyeaXmPanZahzCTvMLUaWzCzVO3v8crrvoyHY8LxYp7HJ33J0MkRpNAfTzalld9xQkdrJww5uw59cbNAWblnmiV94/0tldC3MpRpvGDmki8LCIbiK/AEC6IAHYUm1hfiuYWcklss9o3L3+x74ji7kvyI4Y1TxFA+5iPwaQ/CEeSvFgOtahXl1l9G36AQw0E9bzpWQtUnFd4G1oxHrZvk3k/FjYPLA== X-Yahoo-Newman-Id: 53692.16054.bm@smtp138.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: d_RnD4MVM1kXq8OFjY0S2o1fdYvyUYr7LsRfoPUyJZNmS58 5AlHgrkKLdQ2r_Kgpwptoi2PbkYzmO4SHVtAguJffuJ4aV26hawsdbJAH0kL Q_Nn2WoftjcuCcaHGrl6Vox2AVMUith0R2KW9IcMZBEwoBm.0LKqEa1dPIaJ HIR86S4nkYK1COngUCGRaoJtsfLmYOFrRqxqrn3Sx2sOczhF0uV9fv.TR4HA bKJy26I6JioSsyqplXC0yzibSwo9qADBVR.GBjToUoGCL_uXOnm87EcCeA.1 j_YBM_xeJ3ES_Z.ZoIsSUMSccmWZeW6u8mEHTSvo.Q4v3Jgb4FCQ4PaHm5r5 9KFeI_O6.69QQ17U.lEZi9kXrVNshJbzwSdx5.8VVmxtTiNFd0IkEjZ2kTLl .SGRRcc6GZai8GDqnDWxAKUx0WyICeztC1lsuqjj5BASgcNM_hYGoT93eHYm aC4sk5JfzjbYWVGz2sAcSqf9.14DFPj1mDHWyB4f8UIidyAO1QwELER35DxG QYS94zGGmxWAGKNs0fB_ADGmSCrzRJXUkr5yAe5xjH_g- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <8eb6dce0-50d7-5ab2-503a-194c1de2e45d@redhat.com> From: Oliver Kiddle References: <8eb6dce0-50d7-5ab2-503a-194c1de2e45d@redhat.com> To: zsh workers Subject: Re: zsh virsh completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16121.1468274870.1@hydra.kiddle.eu> Date: Tue, 12 Jul 2016 00:07:50 +0200 Message-ID: <16122.1468274870@hydra.kiddle.eu> Marko Myllynen wrote: > Below is a patch to implement basic completion for the virsh(1) [1] > command from libvirt [2], it completes all virsh commands and their > respective options. The function should probably be named _libvirt then - in much the same way as we use e.g. _subversion for svn. > - virsh help output is pretty much like --help output of any > other program, is there a trick to make the option descriptions also > available when completing virsh command options? If you don't use _arguments --, you can parse the output manually. > - would it make sense (or is it perhaps already possible somehow) to > optionally enable "best guess" completion for all commands which have > no command specific completion rules available yet? There are lots of There are commands where running the command with --help/-h or whatever could do something destructive. I forget which command it was but I remember years ago finding that a completion was spewing messages into syslog. If it was going to be a catch-all default, it might be safer to use man pages as the source. > +_arguments -A "-*" -C -S -s -w \ -w, really? That's rare. > + _cache_virsh_cmds=( ${="$(virsh help 2>&1 | awk '!/:/ {print $1}')"} ) You should use _call_program as a wrapper around virsh. > + _values -w options ${=_cache_virsh_cmdopts[$cmd]} && ret=0 I'm not convinced that _values is gaining you anything over a plain compadd (with _wanted). I wouldn't typically use it with generated matches. If you want the duplicate removal, use -F words With this in place there's no filename completion which can be quite annoying if you need to complete files. So unless virsh sub-commands never take filenames as arguments, I'd have it fallback to _default. In this case, using _alternative. Also, for option completion, it should check the prefix-needed style. Oliver