add command runner util

This commit is contained in:
2026-01-31 16:56:18 -05:00
parent 7fc4498dd7
commit b1ef556eb5
4 changed files with 21 additions and 2 deletions

View File

@@ -16,4 +16,4 @@ lint:
$(GO) fmt ./...
install: build
@cp fes /usr/bin/local
@cp fes /usr/local/bin

View File

@@ -650,6 +650,14 @@ return site</code></pre>
<td><code>util.copyright(link: string, holder: string)</code></td>
<td>Used when setting the website copyright holder.</td>
</tr>
<tr>
<td><code>util.ls(dir)</code></td>
<td>Returns a table of the files in the given directory</td>
</tr>
<tr>
<td><code>util.run(cmd)</code></td>
<td>Returns the output of the provided command. stdout only.</td>
</tr>
</tbody>
</table>
<h3>Dkjson</h3>

View File

@@ -32,4 +32,15 @@ function M.ls(dir)
return t
end
function M.run(cmd)
cmd = cmd or "echo nil"
local p = io.popen(cmd)
if not p then
return nil
end
local r = p:read("*a"):gsub("%s+$", "")
p:close()
return r
end
return M

View File

@@ -9,7 +9,7 @@ var gitCommit string = "devel"
const PROGRAM_NAME string = "fes"
const PROGRAM_NAME_LONG string = "fes/fSD"
const VERSION string = "1.1.1"
const VERSION string = "1.2.0"
func Version() {
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)