aboutsummaryrefslogtreecommitdiff
path: root/bin/generate-events
diff options
context:
space:
mode:
Diffstat (limited to 'bin/generate-events')
-rwxr-xr-xbin/generate-events38
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/generate-events b/bin/generate-events
new file mode 100755
index 0000000..c4a0c1c
--- /dev/null
+++ b/bin/generate-events
@@ -0,0 +1,38 @@
1#!/bin/bash
2events=$(cat)
3echo 'package eventlogging
4/*
5 * THIS FILE IS AUTOGENERATED
6 * DO NOT EDIT MANUALLY!!!
7 */
8
9import (
10 "fagott.pw/charakterin"
11)
12
13'
14
15echo "var Events = []string{"
16while read event
17do
18 cat <<EOT
19 "$event",
20EOT
21done <<<"$events"
22echo '}
23'
24
25while read event
26do
27 funcName=$(sed -r 's/(^|_)(.)([^_]*)/\2\L\3/g' <<<$event)
28 cat <<EOT
29func (l *EventLogger) ${funcName}(user *charakterin.User, data ${funcName}Data) {
30 if user != nil {
31 data.User = user.Name
32 data.UserAgent = user.Agent
33 }
34 l.base.Log("$event", data)
35}
36
37EOT
38done <<<"$events"