summaryrefslogtreecommitdiff
path: root/headers.lua
blob: 680142ddc7317284d516dd3bc61ad7e6d2105502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env lua
local args = require "pl.lapp" [[
Prints list of headers from a standard or available standards
	-d  (string default 'db/')      Directory where definitions are placed
	<selection>  (optional string)  Standard to display headers for
]]
local dir = require "pl.dir"
local parser = require "headers.parser".new()
local definitions = dir.getfiles(args.d, "*.lua")
for _, filename in pairs(definitions) do
	local handle = io.open(filename)
	local data = handle:read("a")
	handle:close()
	parser:parse(data)
end
if args.selection then
	local headers = parser:get_headers(args.selection)
	if not headers then
		os.exit(1)
	end
	for _, header in pairs(headers) do
		print(header)
	end
	return
end
for _, tag in pairs(parser:get_tags()) do
	print(tag)
end