I'm working on completions for zfs and zpool. These use the now-popular
"subcommand" structure, but very few of the subcommands work on files.
Most of them work on zfs datasets (haven't started on zpool yet), but some
work on other things associated with them - properties, permissions, users
and groups so far. While I can complete those, which I need to complete
against depends on which argument I'm looking at. The one I've got
partially working is "get", for getting property information:

       zfs   get   [-r|-d  depth]  [-Hp]  [-o  field[,...]  [-t
 type[,...]]  [-s
       source[,...] "all" | property[,...] filesystem|volume|snapshot ...

The problem is that it completes against properties (and "all") for the
first argument and against three flavors of dataset for the second. I can
do both of those, but figuring when to apply them is problematical.  My
current code just counts arguments that don't start with a "-", but that
means that "zfs -d 2 <TAB>" completes against datasets, not properties.

So, can someone suggest an example of handling this kind of thing? The
things I thought of all seem to be not quite right, or generated and not
handling the different search spaces.

Second issue. Completion handling for the subcommand style commands seems
particularly fragile, in that a bug in the handling of one subcommand can
break completion handling for other subcommands. Makes me really want
automated tests for the ones I've finished. Any suggestions on how to
automate testing completions?
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to