summaryrefslogtreecommitdiff
path: root/repo/www/generate-lua-config.py
diff options
context:
space:
mode:
Diffstat (limited to 'repo/www/generate-lua-config.py')
-rwxr-xr-xrepo/www/generate-lua-config.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/repo/www/generate-lua-config.py b/repo/www/generate-lua-config.py
new file mode 100755
index 0000000..0a00443
--- /dev/null
+++ b/repo/www/generate-lua-config.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+
+from sys import argv
+
+
+TEMPLATE = '''\
+local config = {{}}
+
+config.EXTENSIONS = {{ {EXTENSIONS} }}
+
+return config
+'''
+
+
+def _quote(s):
+ return f"'{s}'"
+
+
+def main(arguments):
+ pairs = (arg.split('=') for arg in arguments)
+
+ formatters = {
+ 'EXTENSIONS': lambda v: ', '.join(map(_quote, v.split()))
+ }
+
+ parameters = {
+ key: formatters[key](value) for (key, value) in pairs
+ }
+
+ print(TEMPLATE.format_map(parameters), end='')
+
+
+if __name__ == '__main__':
+ main(argv[1:])