Run scripts

This commit is contained in:
Wancat
2022-10-19 09:12:33 +08:00
parent 268b488fea
commit 25503867f9
3 changed files with 29 additions and 0 deletions

18
scripts.go Normal file
View File

@@ -0,0 +1,18 @@
package main
import (
"io"
"os/exec"
)
var SCRIPTS = map[string][]string{
"balance": {"b"},
"register": {"r"},
}
func executeScript(w io.Writer, name string) (err error) {
cmd := exec.Command("ledger", append([]string{"-f", LEDGER_FILE}, SCRIPTS[name]...)...)
cmd.Stdout = w
cmd.Stderr = w
return cmd.Run()
}