# GLOBALS set CMD "$argv[1]" set CMDS beamer door help tv function error echo $argv[2..] 1>&2 return $argv[1] end set _descr_beamer "Control the beamer in the lounge" set _usage_beamer "" function cmd_beamer switch $argv[1] case on ssh chaos@lounge.cccda.de beamer-on case off ssh chaos@lounge.cccda.de beamer-off case "*" error 1 "$(cmd_help beamer)" end end set _descr_door "Control the door" function cmd_door ssh door@door.cccda.de $argv end set _descr_help "Display this message" function cmd_help set cmd "$argv[1]" if [ "$cmd" != "" ] echo "\ $(eval echo \$_descr_$cmd) Usage: chaosctl $cmd $(eval echo \$_usage_$cmd)" else echo "\ The chaosctl utility Usage: chaosctl COMMANDS" for cmd in $CMDS echo -e " $cmd\t$(eval echo \$_descr_$cmd)" end end end set _descr_tv "\tControl the TV in the kitchen" function cmd_tv ssh chaos@kitchen.cccda.de tv $argv end if [ "cmd_$CMD" = cmd_ ] error 1 "$(cmd_help)" exit $status end if type -q "cmd_$CMD" cmd_$CMD $argv[2..] else error 127 "No such subcommand '$CMD'" end