diff options
author | Aki <please@ignore.pl> | 2024-08-20 22:11:19 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-08-20 22:11:19 +0200 |
commit | 580835fb52cfe2ba46f3cd5980ee388d2408f214 (patch) | |
tree | b7b1d5d3e14c0551b75c1fa6b50370c8de0a91bb /headers.lua | |
parent | 82fffc923163efd50342a96a4556821e2a50446d (diff) | |
download | headers-580835fb52cfe2ba46f3cd5980ee388d2408f214.zip headers-580835fb52cfe2ba46f3cd5980ee388d2408f214.tar.gz headers-580835fb52cfe2ba46f3cd5980ee388d2408f214.tar.bz2 |
Command implementation will now output the query results
While this no longer depends on side-effects to output the results, it
still depends on side-effects when parsing in a typical OOP fashion.
This works for now but is not really safe or maintainable. Luckily,
this tool is not intended for long term maintenance so I'll be leaving
it at that. I already procrastinated enough and the main goal - a
showcase of particular use of Lua as DSL - has been accomplished.
Diffstat (limited to 'headers.lua')
-rwxr-xr-x | headers.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/headers.lua b/headers.lua index 8726615..680142d 100755 --- a/headers.lua +++ b/headers.lua @@ -11,7 +11,18 @@ for _, filename in pairs(definitions) do local handle = io.open(filename) local data = handle:read("a") handle:close() - if parser:parse(data, args.selection) then - return -- interface is yet to be properly defined, this allows only for first-result queries + 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 |