1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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 "<on|off>"
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 <command>
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