summaryrefslogtreecommitdiff
path: root/xS/xS-gen-replies.awk
blob: 94a338f9a8bae6b5790e05e78dfbe477945247d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/awk -f
/^[0-9]+ *(ERR|RPL)_[A-Z]+ *".*"$/ {
	match($0, /".*"/)
	ids[$1] = $2
	texts[$2] = substr($0, RSTART, RLENGTH)
}

END {
	print "package main"
	print ""
	print "const ("
	for (i in ids)
		printf("\t%s = %s\n", ids[i], i)
	print ")"
	print ""
	print "var defaultReplies = map[int]string{"
	for (i in ids)
		print "\t" ids[i] ": " texts[ids[i]] ","
	print "}"
}