aboutsummaryrefslogtreecommitdiff
path: root/bin/generate-events
blob: c4a0c1cedb7f4c37cb54d09bce8b94afdc085882 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
events=$(cat)
echo 'package eventlogging
/*
 * THIS FILE IS AUTOGENERATED
 * DO NOT EDIT MANUALLY!!!
 */

import (
	"fagott.pw/charakterin"
)

'

echo "var Events = []string{"
while read event
do
	cat <<EOT
	"$event",
EOT
done <<<"$events"
echo '}
'

while read event
do
	funcName=$(sed -r 's/(^|_)(.)([^_]*)/\2\L\3/g' <<<$event)
	cat <<EOT
func (l *EventLogger) ${funcName}(user *charakterin.User, data ${funcName}Data) {
	if user != nil {
		data.User = user.Name
		data.UserAgent = user.Agent
	}
	l.base.Log("$event", data)
}

EOT
done <<<"$events"