aboutsummaryrefslogtreecommitdiffstats
path: root/commands/caps
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-12-18 22:15:38 +0100
committertv <tv@nomic.retiolum>2013-12-18 22:15:38 +0100
commit5886952793f4ccef0151930fc0500af8c9b69fea (patch)
treed0db8a78b58df9a8a340f4cb950916624e43f64f /commands/caps
parent90815d6eb4f2d1c27e298543a976caf975af140f (diff)
Reaktor: caps show all commands w/capname prop
Diffstat (limited to 'commands/caps')
-rwxr-xr-xcommands/caps24
1 files changed, 19 insertions, 5 deletions
diff --git a/commands/caps b/commands/caps
index caa1fe0..eb1d97a 100755
--- a/commands/caps
+++ b/commands/caps
@@ -1,5 +1,19 @@
-#! /bin/sh
-exec echo 'TODO: need access to config.json'
-set -euf
-cd public_commands
-echo `ls`
+#! /usr/bin/env python
+import imp
+import os
+
+def load_config(filename):
+ dirname = os.path.dirname(filename)
+ modname, ext = os.path.splitext(os.path.basename(filename))
+ file, pathname, description = imp.find_module(modname, [ dirname ])
+ return imp.load_module(modname, file, pathname, description)
+
+def not_none(x):
+ return x != None
+
+def pluck(name):
+ return lambda x: name in x.keys() and x[name] or None
+
+config = load_config(os.environ['config_filename'])
+
+print(' '.join(filter(not_none, map(pluck('capname'), config.irc_commands))))