Add ledger initial file option, add meta viewport
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
.env
|
.env
|
||||||
test.txt
|
test.txt
|
||||||
|
ledger-quicknote
|
||||||
|
|||||||
7
config.go
Normal file
7
config.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
var SCRIPTS = map[string][]string{
|
||||||
|
"balance assets": {"b", "assets", "-X", "$"},
|
||||||
|
"register": {"r", "--tail", "10"},
|
||||||
|
"balance this month": {"b", "-b", "this month"},
|
||||||
|
}
|
||||||
7
main.go
7
main.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -15,7 +16,8 @@ import (
|
|||||||
var ledgerTpl *template.Template
|
var ledgerTpl *template.Template
|
||||||
var htmlTpl *template.Template
|
var htmlTpl *template.Template
|
||||||
|
|
||||||
const LEDGER_FILE = "test.txt"
|
var LEDGER_FILE string
|
||||||
|
var LEDGER_INIT string
|
||||||
|
|
||||||
type TxData struct {
|
type TxData struct {
|
||||||
Name string
|
Name string
|
||||||
@@ -27,6 +29,9 @@ type TxData struct {
|
|||||||
func init() {
|
func init() {
|
||||||
ledgerTpl = template.Must(template.ParseGlob("tx/*"))
|
ledgerTpl = template.Must(template.ParseGlob("tx/*"))
|
||||||
htmlTpl = template.Must(template.ParseGlob("templates/*.html"))
|
htmlTpl = template.Must(template.ParseGlob("templates/*.html"))
|
||||||
|
flag.StringVar(&LEDGER_FILE, "f", "example.txt", "ledger journal file")
|
||||||
|
flag.StringVar(&LEDGER_INIT, "i", "~/.ledgerrc", "ledger initiation file")
|
||||||
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -6,18 +6,12 @@ import (
|
|||||||
"os/exec"
|
"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) {
|
func executeScript(w io.Writer, name string) (err error) {
|
||||||
script, ok := SCRIPTS[name]
|
script, ok := SCRIPTS[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("%s script not found", name)
|
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.Stdout = w
|
||||||
cmd.Stderr = w
|
cmd.Stderr = w
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Ledger Quick Note</title>
|
<title>Ledger Quick Note</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Ledger Quick Note</h1>
|
<h1>Ledger Quick Note</h1>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Ledger Quick Note</title>
|
<title>Ledger Quick Note</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Comfirm new Tx</h1>
|
<h1>Comfirm new Tx</h1>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Ledger Quick Note</title>
|
<title>Ledger Quick Note</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Ledger Quick Note</h1>
|
<h1>Ledger Quick Note</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user