Last active 1765621367

dch's Avatar dch revised this gist 1765621366. Go to revision

1 file changed, 23 insertions

repos.flua(file created)

@@ -0,0 +1,23 @@
1 + #!/usr/libexec/flua
2 +
3 + -- usage - chmod, then `pkg repositories | repos.flua`
4 +
5 + local ucl = require("ucl")
6 + local parser = ucl.parser()
7 +
8 + -- read from stdin
9 + local data = io.stdin:read("*all")
10 +
11 + -- try to convert to lua table
12 + local ok, err = parser:parse_string(data)
13 +
14 + if not ok then
15 + io.stderr:write("Error parsing UCL: " .. err .. "\n")
16 + os.exit(1)
17 + end
18 +
19 + -- fetch the root object
20 + data = parser:get_object()
21 +
22 + -- pretty-print the lua table as json
23 + print(ucl.to_format(data, "json"))
Newer Older