Please ignore complexity of supplied examples... It's really not for that kind of use. I have lots of scripts that do something like this (and most of them are not in bash :)...):
while read ARG; do
if validate $ARG; then
run_something $ARG
fi
done
Most of my "validate" pieces are bash functions and most "run_something" return lengthy CSV datablocks.
Then, there is the javascript that uses user mouse (and other signals) to generate arguments to send to websocketd and draw pretty visuals based on data that arrives back.