diff options
Diffstat (limited to 'bin/generate-events')
-rwxr-xr-x | bin/generate-events | 38 |
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 | ||
2 | events=$(cat) | ||
3 | echo 'package eventlogging | ||
4 | /* | ||
5 | * THIS FILE IS AUTOGENERATED | ||
6 | * DO NOT EDIT MANUALLY!!! | ||
7 | */ | ||
8 | |||
9 | import ( | ||
10 | "fagott.pw/charakterin" | ||
11 | ) | ||
12 | |||
13 | ' | ||
14 | |||
15 | echo "var Events = []string{" | ||
16 | while read event | ||
17 | do | ||
18 | cat <<EOT | ||
19 | "$event", | ||
20 | EOT | ||
21 | done <<<"$events" | ||
22 | echo '} | ||
23 | ' | ||
24 | |||
25 | while read event | ||
26 | do | ||
27 | funcName=$(sed -r 's/(^|_)(.)([^_]*)/\2\L\3/g' <<<$event) | ||
28 | cat <<EOT | ||
29 | func (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 | |||
37 | EOT | ||
38 | done <<<"$events" | ||