You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
567 B

package cmd
import (
"fmt"
"os"
"jxs.me/proto/mps"
)
func readDb() (*mps.TransactionLog, error) {
source := "txnlog.dat"
sourceFile, err := os.Open(source)
if err != nil {
return nil, err
}
defer sourceFile.Close()
return mps.Parse(sourceFile)
}
func Root(args []string) error {
if len(args) == 0 {
return fmt.Errorf(`
Missing Command. Supported options:
balance
users
`)
}
switch args[0] {
case "users":
return users(args[1:])
case "balance":
return balance(args[1:])
default:
return fmt.Errorf("Unknown command: %s", args[0])
}
}