listchooser command

Presents a graphical interface to the user to choose from a list of options.

All Usage Options Examples

Usage

listchooser [-r] [-p] [-t title] [-h help] choice1 choice2 ...

Options

-r

Radio (only one choice can be selected).

When this option is not present, the command will return multiple choices as a space-separated list.

-p

Output the string corresponding to the choice instead of the index number.

-t

Title for choice window.

-h

Help string to present to the user (only in non-graphical mode)

Examples

listchooser -p -t "What is your quest?" \
    "To seek the holy grail" \
    "To count to 3 without skipping 2" \
    "To slay a dragon"

Outputs "To seek the holy grail" if user chooses first option, "To count to 3 without skipping 2" if the user chooses the second option, etc. If the user chooses multiple options, they are returned as a space separated list:

"To seek the holy grail" "To slay a dragon"
listchooser -r -t "What is your favorite color?" \
    Red Blue "No Yellow"

Outputs 0 if user chooses the first option, 1 if the user chooses the second option, etc.