Add ledger initial file option, add meta viewport

This commit is contained in:
Wancat
2022-10-19 10:15:59 +08:00
parent 1f82bd4bcb
commit b79b82798d
7 changed files with 18 additions and 8 deletions

View File

@@ -6,18 +6,12 @@ import (
"os/exec"
)
var SCRIPTS = map[string][]string{
"balance": {"b"},
"register": {"r"},
"expenses this month": {"b", "expenses", "-b", "this month"},
}
func executeScript(w io.Writer, name string) (err error) {
script, ok := SCRIPTS[name]
if !ok {
return fmt.Errorf("%s script not found", name)
}
cmd := exec.Command("ledger", append([]string{"-f", LEDGER_FILE}, script...)...)
cmd := exec.Command("ledger", append([]string{"--init-file", LEDGER_INIT}, script...)...)
cmd.Stdout = w
cmd.Stderr = w
return cmd.Run()