moonmath/moonmath.go
Sam Fredrickson ba4e803eea
All checks were successful
Build & Test / Main (push) Successful in 1m31s
Make it easier to use other assets.
2024-03-21 17:39:10 -07:00

43 lines
812 B
Go

package main
import (
"fmt"
"os"
"strings"
"code.humancabbage.net/sam/moonmath/coindesk"
"code.humancabbage.net/sam/moonmath/config"
"code.humancabbage.net/sam/moonmath/tui"
"github.com/alecthomas/kong"
)
var CLI struct {
Asset string `short:"a" default:"BTC" help:"Asset to project."`
ConfigFile string `short:"c" help:"Path to YAML configuration file."`
}
func main() {
ctx := kong.Parse(&CLI)
if ctx.Error != nil {
fail(ctx.Error)
}
allCfg, err := config.Load(CLI.ConfigFile)
if err != nil {
fail(err)
}
CLI.Asset = strings.ToUpper(CLI.Asset)
cfg, err := allCfg.GetData(coindesk.Asset(CLI.Asset))
if err != nil {
fail(err)
}
p := tui.New(cfg)
if _, err := p.Run(); err != nil {
fail(err)
}
}
func fail(err error) {
fmt.Printf("program error: %v\n", err)
os.Exit(1)
}