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

Re: completion for 'alerter'

On Thu, 2020-03-05 at 23:45 -0500, TJ Luoma wrote:
> These are the options for `alerter`
> -help
> -json
> -message VALUE
> -remove ID
> -list ID
> -reply VALUE
> -actions VALUE1,VALUE2
> -dropdownLabel VALUE
> -title VALUE
> -subtitle VALUE
> -closeLabel VALUE
> -sound NAME
> -group ID
> -sender ID
> -appIcon URL
> -contentImage URL
> -timeout NUMBER

Best thing to do for something like this is to copy another
straightforward completion.  For example, a search for something that
handles '-help' reveals Completion/Unix/Command/_tardy in the zsh
distribution --- it doesn't get much simpler than that.  All you really
need to know here is that if there is a colon, the thing immediately
after the colon describes the argument; if there are two colons, the
stuff after the second is completion of the argument (e.g. your VALUE or
ID); the stuff in parentheses is literal value to be completed, and the
things beginning "_" are completion functions to be called to add the
values.  There are functions you can call for pretty much anything
generic e.g. _urls for (surprise!) URLs.  Copy it to _alerter, change
the line at the top to say "#compdef _alerter", change the list of
options, and that's it basically working.

If you want a professionally edited step-by-step guide, your best bet is
probably Oliver's chapter 15 from From Bash to Z Shell,
http://www.bash2zsh.com/ although that web site does have some other
potentially useful links.


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