1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-20 23:52:15 +00:00
stmbl/tools/create_cmd.py

25 lines
777 B
Python
Raw Permalink Normal View History

2018-04-07 00:00:04 +00:00
#!/usr/bin/env python
2017-02-25 21:37:29 +00:00
import re
import sys
cmd = []
for infile in sys.argv[1:]:
with open(infile) as f:
2017-04-12 02:05:46 +00:00
for line_number, line in enumerate(f):
2017-07-12 20:12:04 +00:00
match = re.search('COMMAND\("(\w*)", *(\w*), *"([^"]*)"\);', line)
2017-02-25 21:37:29 +00:00
if match:
2017-04-12 02:05:46 +00:00
cmd.append((match.groups(), infile, line_number))
2017-02-25 21:37:29 +00:00
2018-04-07 00:00:04 +00:00
print ("//generated by " + sys.argv[0] + " DO NOT EDIT")
2017-02-25 21:37:29 +00:00
2017-07-12 20:12:04 +00:00
for (name, ptr, doc), file_name, line_number in cmd:
2018-04-07 00:00:04 +00:00
print ("extern void " + ptr + "(char *); // found in " + file_name + " line: " + str(line_number + 1))
2017-04-12 02:05:46 +00:00
2018-04-07 00:00:04 +00:00
print ("\n")
2017-02-25 21:37:29 +00:00
2018-04-07 00:00:04 +00:00
print ("cmd_t cmd[] = {")
2017-07-12 20:12:04 +00:00
for (name, ptr, doc), file_name, line_number in cmd:
2018-04-07 00:00:04 +00:00
print (" {\"" + name + "\", \"" + doc + "\", " + ptr + "}, // found in " + file_name + " line: " + str(line_number + 1))
print ("};")