Hi David, On Fri, 8 Dec 2017, David Guyot wrote: > I'm working on completions for zfs and zpool commands, but there are > some shared functions between them, for instance for zpool completions > accepting zfs properties. On one hand, I'm reluctant to duplicate code, > as it is likely that, when a copy will be improved, the other one will > miss it; on the other hand, such functions could be helpful for other > programs, like the ones listing available pools and properties. > > For these reasons, I would like to migrate such functions in > share/functions, but I have some questions: > 1. would it be right to place such helper functions in share/functions?
Yes. Generally these helper functions, which are not intended to be run directly by end-users, are called `__fish_print_{object}` or `__fish_complete_{object}`, depending on whether they return a simple list or a tab-separated list of items and descriptions. If you only need the function for a single completion, it can go inside the completion itself as a standalone function. > 2. are there established criteria for judging the relevance of such > placements? For instance, accept functions only displaying lists of > suggestions, not altering the already typed-in command? I'm not sure I understand the question here, but if you have a look in the source under `share/functions/__fish_*` you can see some examples. In general the completion framework changes the command line, rather than being directly done by functions or completions. (Functions bound to certain keys are another matter.) > 3. which directory should I place such functions in, on an installed > fish instance, to test them? ~/.config/fish/functions? That's the easiest way! > Please note that, for 1. and 3., I'm almost sure of the answer, but not > totally, hence the questions. Hope that helps. David Adam zanc...@ucc.gu.uwa.edu.au ------------------------------------------------------------------------------ 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