add command runner util
This commit is contained in:
2
Makefile
2
Makefile
@@ -16,4 +16,4 @@ lint:
|
||||
$(GO) fmt ./...
|
||||
|
||||
install: build
|
||||
@cp fes /usr/bin/local
|
||||
@cp fes /usr/local/bin
|
||||
|
||||
@@ -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>
|
||||
|
||||
11
lib/util.lua
11
lib/util.lua
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user