commit 0dd6b39343014b32541d4bd80543a98b48d28eb4
parent a20f35fb203a5428c92171070d79fa11c74532a3
Author: Hannah Izzie Gesser <hannah@totient.eu>
Date: Mon, 9 Jun 2025 21:47:06 +0200
parent a20f35fb203a5428c92171070d79fa11c74532a3
Author: Hannah Izzie Gesser <hannah@totient.eu>
Date: Mon, 9 Jun 2025 21:47:06 +0200
Add package chaosctl
2 files changed, 70 insertions(+), 0 deletions(-)
A
|
65
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/packages/chaosctl/chaosctl.fish b/packages/chaosctl/chaosctl.fish @@ -0,0 +1,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
diff --git a/packages/chaosctl/default.nix b/packages/chaosctl/default.nix @@ -0,0 +1,5 @@ +{ + writers, + ... +}: +writers.writeFishBin "chaosctl" ./chaosctl.fish