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

Re: completion for 'alerter'

On 3/6/20, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> 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.

A minor correction that this should say "#compdef alerter" without the
underscore, or it would just complete options to the completer.

Mikael Magnusson

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