Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Complicated Completions

Hi. I'm new to the list - I did try to search the archives, but I'm afraid my question is of a more abstract kind.

I have spent some time trying to get to know the completion system. My aim is to create completion functions for some of the useful and surprisingly well-documented command line tools specific to Mac OS X (hdiutil, diskutil, defaults, SystemStarter, ditto to mention a few). The thing is, some of them use rather peculiar and complex command line syntaxes, so creating useful completions is quite a challenge.

I would like to request some guidance in creating a completion function for the hdiutil command. As you know, the documentation is thorough, but not very friendly to new developers, so I believe all I need is some help getting started.

I will begin by describing the command line syntax of hdiutil, using snippets from the man page.

     hdiutil verb [options]

Verb is one of the following:
attach, detach, verify, create, convert, burn, help, info, load, checksum, eject (synonym for detach), flatten, unflatten, imageinfo, mount (synonym for attach), mountvol, unmount, plugins, internet-enable, resize, segment, partition, makehybrid, pmap

The set of allowed options depends on the sub command (verb). All verbs accept the following optional options (duh), all mutually exclusive:

Many verbs accept these options:
	-srcimagekey <key>=<value>
	-tgtimagekey <key>=<value>
	-encryption [crypto method]
	-passphrase password
	-shadow [shadow file]

Many verbs take additional options that are specific to that verb. For example, convert takes the following additional arguments / options:
	imagefile (source file name)
	-format fmt (fmt is one of UDRW UFBI UDRO UDCO...DC42)
	-o dest (destination file name)
	-align sector_alignment
	-segmentSize [sector count]
	-segmentSize <??b|??k|??m|??g|??t??p|??e> like mkfile(8)

Several commands (attach|verify|compact|convert|burn|checksum|chpass|*flatten|fsid|image- info|internet-enable|resize|segment|partition|pmap) take exactly one filename argument - of a .dmg file. That corresponds to imagefile in teh above convert example.

Could someone outline how I would arrange the completion function for this command? The _ifconfig sample gave me some hints, but I'm having trouble extending it past the verb...

/ Rgds, David Remahl

Messages sorted by: Reverse Date, Date, Thread, Author