From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14974 invoked from network); 22 Sep 2008 17:16:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Sep 2008 17:16:35 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 42804 invoked from network); 22 Sep 2008 17:16:29 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Sep 2008 17:16:29 -0000 Received: (qmail 21961 invoked by alias); 22 Sep 2008 17:16:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25719 Received: (qmail 21948 invoked from network); 22 Sep 2008 17:16:23 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 22 Sep 2008 17:16:23 -0000 Received: from friskymail-a5.g.dreamhost.com (lax-green-bigip-5.dreamhost.com [208.113.200.5]) by bifrost.dotsrc.org (Postfix) with ESMTP id 27AF58058998 for ; Mon, 22 Sep 2008 19:16:11 +0200 (CEST) Received: from [192.168.0.207] (pat.foofus.net [64.73.34.170]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by friskymail-a5.g.dreamhost.com (Postfix) with ESMTP id B9250FA190 for ; Mon, 22 Sep 2008 10:16:04 -0700 (PDT) Message-ID: <48D7D2D3.2070303@foofus.net> Date: Mon, 22 Sep 2008 12:16:03 -0500 From: Bismark User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: zsh-workers@sunsite.dk Subject: Re: completion function help References: <48D40EEB.3040404@foofus.net> <237967ef0809191354k33cfa5eeib9d5e5df341032c4@mail.gmail.com> In-Reply-To: <237967ef0809191354k33cfa5eeib9d5e5df341032c4@mail.gmail.com> X-Enigmail-Version: 0.95.0 OpenPGP: id=10E8C93F Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig5D186EA4A680B12FF8D00D00" X-Virus-Scanned: ClamAV 0.92.1/8308/Mon Sep 22 15:43:13 2008 on bifrost X-Virus-Status: Clean This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5D186EA4A680B12FF8D00D00 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mikael Magnusson wrote: > 2008/9/19 Bismark : >> I'm trying to right a command completion function and I'm stuck. I've= >> been looking through examples and the documentation but having no luck= =2E >> >> What I'm looking for is for the parameters for an option to a command = to >> have a description. I've gotten the completion to work for the command= >> but when I complete the option I only get the values. >> >> $ medusa - >> option >> -C -- File containing combo entries. (see man page) >> -H -- Reads Target specifications from a file. >> -P -- Reads Passwords from a file. >> -U -- Reads Usernames from a file. >> -e -- Additional password checks >> -h -- Target hostname or IP address. >> -p -- Password. >> -u -- Username. >> >> $ medusa -e >> Additional password checks >> n ns s >> >> I would like it to display something like the following >> >> $ medusa -e >> Additional password checks >> n -- No Password >> s -- Username =3D Password >> ns -- No Password & Username =3D Password >> >> What is the best way to go about doing this? >=20 > It would of course help a lot if you also posted your code, but at a gu= ess, > where you have -d array in your compdef call, change it to -ld array, w= here > array is the array with your descriptions, i think. Maybe the problem i= s > you don't have a -d array at all. ie > mydescriptions=3D('No Password' 'Username =3D Password' etc) > compdef blabla -ld mydescriptions blabla I'm doing this for Medusa http://www.foofus.net/jmk/medusa/medusa.html by the way. Yes including the code probably would have helped, sorry about that. I think I have it working now though I do not know if it's the proper or most efficient way to do it. What I have so far is below: ####### _medusa ###### #compef medusa local expl context state line ret=3D1 _select_module() { local modules modules=3D( $(medusa -d | grep + | awk '/.mod/ {print $2}' | cut -d"." -f 1) ) _wanted select-module expl 'Module' compadd "$@" -a - modules } _arguments \ '-h[Target hostname or IP address.]:Hostname or IP Address' \ '-H[Read Targets from a file.]:Hosts file:_files' \ '-u[Username.]:Username' \ '-U[Read Usernames from a file.]:Username file:_files' \ '-p[Password.]:Password' \ '-P[Read Passwords from a file.]:Password file:_files' \ '-C[File containing combo entries. (see man page)]:Combo file:_files' \ "-e[Additional password checks]:Additional password checks:_values 'Additional password checks' 'n[No Password]' 's[Password =3D Username]' 'ns[No Password & Password =3D Username]'" \ '-O[File to append log information to.]:xiLlog file:_files' \ '-M[Name of the module to execute (without the .mod extension)]:Module:_select_module' \ '*-m[Parameter to pass to the module.]:Module Parameters' \ '-d[Dump all known modules.]:Dump Modules' \ '-n[Use for non-default TCP port number.]:tcp port' \ '-s[Enable SSL.]:Enable SSL' \ '-g[Give up after trying to connect for NUM seconds (default 3).]:Retry seconds' \ '-r[Sleep number of seconds between retry attempts (default 3).]:Sleep seconds' \ '-R[Attempted retries before giving up. The total number of attempts will be retries + 1.]:Retries' \ '-t[Total number of logins to be tested concurrently]:Concurrent Logins' \ '-T[Total number of hosts to be tested concurrently.]:Concurrent Hosts' \ '-L[Parallelize logins using one username per thread.]:Parallelize' \ '-f[Stop scanning host after first valid username/password found.]:Stop scan after host' \ '-F[Stop audit after first valid username/password found on any host.]:Stop scan after username' \ '-b[Suppress startup banner]:Suppress Banner' \ '-q[Display module=E2=80=99s usage information.]:Module Usage' \ '-v[Verbose level (0 - 6)]:Verbosity:(0 1 2 3 4 5 6)' \ '-w[Error debug level (0 - 10)]:Debug:(0 1 2 3 4 5 6 7 8 9 10)' \= '-V[Display version]:Version' && return 0 #### end _medusa #### I also have a couple of other questions along with this one. 1) I know how to setup mutually exclusive arguments, is it possible to configure prerequisite arguments? In medusa you have to select a module '-M ' and then the individual modules themselves can have additional arguments '-m ', but -m doesn't do anything unless -M is given. 2) If it is possible to do #1 can you get the value passed to -M to help complete the values for the -m argument? Thanks, Bismark --------------enig5D186EA4A680B12FF8D00D00 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFI19LTRNC5NhDoyT8RAow7AJ9JSmKRdI9MpuFG9qf8koGijcTLjQCgpX5L E+lKgUSG8m88Ix7CyftQ1cg= =NJMO -----END PGP SIGNATURE----- --------------enig5D186EA4A680B12FF8D00D00--