aboutsummaryrefslogtreecommitdiff
path: root/xS/hid-gen-replies.sh
blob: c32b000cc7b105c101c8ae5761d234c1dac850f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
LC_ALL=C exec awk '
	/^[0-9]+ *(ERR|RPL)_[A-Z]+ *".*"$/ {
		match($0, /".*"/);
		ids[$1] = $2;
		texts[$2] = substr($0, RSTART, RLENGTH);
	}
	END {
		print "package " ENVIRON["GOPACKAGE"] "\n\nconst ("
		for (i in ids)
			printf("\t%s = %s\n", ids[i], i)
		print ")\n\nvar defaultReplies = map[int]string{"
		for (i in ids)
			print "\t" ids[i] ": " texts[ids[i]] ","
		print "}"
	}'