zaphyra's git: tgcNUR

fork of https://git.transgirl.cafe/zaphoid/tgc-nix-user-repository

commit e144e8d615d91c6c20c5ef1ac7bf2b215f4c17c1
parent e9fc0d3c22355b2a3966ca584f7a60b704995b79
Author: Hannah Izzie Gesser <hannah@totient.eu>
Date: Sun, 3 Aug 2025 16:52:24 +0200

pkg: chaosctl: Init
2 files changed, 70 insertions(+), 0 deletions(-)
A
pkgs/chaosctl/chaosctl.fish
|
65
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
pkgs/chaosctl/package.nix
|
5
+++++
diff --git a/pkgs/chaosctl/chaosctl.fish b/pkgs/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/pkgs/chaosctl/package.nix b/pkgs/chaosctl/package.nix
@@ -0,0 +1,5 @@
+{
+  writers,
+  ...
+}:
+writers.writeFishBin "chaosctl" ./chaosctl.fish