choose - Lets the user choose between arguments, or lines of STDIN
FILE=`choose 'Which header file ?' *.h` MY_GROUPS=`groups` chgrp `choose "Change $FILE to which group ?" $MY_GROUPS` $FILE lsusb | choose -f 'Which USB device ?' lsusb | choose -f -m 'Which USB devices ?' case `choose "Which SQL command ?" DELETE INSERT UPDATE` in '') exit ;; DELETE) ...;; INSERT) ...;; UPDATE) ...;; esac
This script offers a shell-level interface to the Term::Clui CPAN-module. The first argument is the question; by default, subsequent arguments are offered as choices; with the -f (Filter) option, the lines of STDIN are offered as the choices.
For the user, it uses the Arrow-keys and Return, or q to quit. If a -m multiple-choice is being offered, then SpaceBar highlights choices additional to the one under the final Return.
This program comes packaged with the Term::Clui module, in the
Causes choose to work as a filter (like grep), so that the user chooses between lines from the standard input. (The default is that the user chooses between the 2nd and all subsequent arguments.)
This offers multiple-choice; the equivalent of calling Term::Clui::choose in a list context.
Prints version number.
20090928 1.1 pod tidied up, and -f options documented 20090927 1.0 first working version
Peter J Billam http://www.pjb.com.au/comp/contact.html
Based on the CPAN module Term::Clui
http://search.cpan.org/perldoc?Term::Clui http://search.cpan.org/~pjb http://www.pjb.com.au/ perl(1)