add command runner util
This commit is contained in:
2
Makefile
2
Makefile
@@ -16,4 +16,4 @@ lint:
|
|||||||
$(GO) fmt ./...
|
$(GO) fmt ./...
|
||||||
|
|
||||||
install: build
|
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><code>util.copyright(link: string, holder: string)</code></td>
|
||||||
<td>Used when setting the website copyright holder.</td>
|
<td>Used when setting the website copyright holder.</td>
|
||||||
</tr>
|
</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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h3>Dkjson</h3>
|
<h3>Dkjson</h3>
|
||||||
|
|||||||
11
lib/util.lua
11
lib/util.lua
@@ -32,4 +32,15 @@ function M.ls(dir)
|
|||||||
return t
|
return t
|
||||||
end
|
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
|
return M
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var gitCommit string = "devel"
|
|||||||
|
|
||||||
const PROGRAM_NAME string = "fes"
|
const PROGRAM_NAME string = "fes"
|
||||||
const PROGRAM_NAME_LONG string = "fes/fSD"
|
const PROGRAM_NAME_LONG string = "fes/fSD"
|
||||||
const VERSION string = "1.1.1"
|
const VERSION string = "1.2.0"
|
||||||
|
|
||||||
func Version() {
|
func Version() {
|
||||||
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)
|
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)
|
||||||
|
|||||||
Reference in New Issue
Block a user