xK/xS/xS-gen-replies.awk

21 lines
377 B
Awk
Raw Normal View History

2022-09-26 12:23:58 +02:00
#!/usr/bin/awk -f
/^[0-9]+ *(ERR|RPL)_[A-Z]+ *".*"$/ {
2022-09-26 12:39:26 +02:00
match($0, /".*"/)
ids[$1] = $2
texts[$2] = substr($0, RSTART, RLENGTH)
2022-09-26 12:23:58 +02:00
}
END {
2022-09-26 12:39:26 +02:00
print "package main"
print ""
print "const ("
2022-09-26 12:23:58 +02:00
for (i in ids)
printf("\t%s = %s\n", ids[i], i)
2022-09-26 12:39:26 +02:00
print ")"
print ""
print "var defaultReplies = map[int]string{"
2022-09-26 12:23:58 +02:00
for (i in ids)
print "\t" ids[i] ": " texts[ids[i]] ","
print "}"
}