I am writing a custom competition function for zsh. Currently, I have the following code
_arguments \
...
'(-G --glitchpct)'{-G+,--glitchpct=}'[Controls how often the characters on screen glitch]'
I am currently specifying that -G VALUE
or glitchpct=VALUE
or --glitchpct VALUE
are acceptable(mutually exclusive as they are part of the same group).
What if I need to have 2 argument values instead of one? That is, I expect to have -G VALUE1 VALUE2
or --glitchpct=VALUE1,VALUE2
. How could I specify this? Also, how would it be different if there are 3, etc. arguments?
Additionally, would it be possible to display a custom message for each argument? Say VALUE1
should display 'float from 0 to 50'
, and VALUE2
should display 'float from 100 to 150'
on the screen. I assume it is possible to do that through the _message
builtin but I am unsure how to make it work. I tried specifying the state like this(this is for only 1 value as I haven't figured out how to use two):
_arguments \
...
'(-G --glitchpct)'{-G+,--glitchpct=}'[Controls how often the characters on screen glitch]:float:->display_float'
...
case "$state" in
(display_float)
_message "sample message"
;;
esac
but this didn't see to display anything. The following form didn't work either:
'(-G --glitchpct)'{-G+,--glitchpct=}'[Controls how often the characters on screen glitch]:float:_message "sample message"
age
is the optional argument. Notice that there is noshift
included in the last bit of the case state which is what makes it optional. Theshift
afteresac
concludes the argument passing.zsh
's competition system, which is supposed to make things easier. That's what I am looking for_message
and 0 mentions of having more than one options for arguments like I need (: