moonmath/moonmath.go

36 lines
602 B
Go
Raw Normal View History

2024-03-17 09:10:05 +00:00
package main
import (
"fmt"
"os"
2024-03-20 04:44:11 +00:00
"code.humancabbage.net/sam/moonmath/config"
2024-03-20 01:38:46 +00:00
"code.humancabbage.net/sam/moonmath/tui"
2024-03-20 04:44:11 +00:00
"github.com/alecthomas/kong"
2024-03-17 09:10:05 +00:00
tea "github.com/charmbracelet/bubbletea"
)
2024-03-20 04:44:11 +00:00
var CLI struct {
ConfigFile string `help:"Path to TOML configuration file."`
}
2024-03-17 09:10:05 +00:00
func main() {
2024-03-20 04:44:11 +00:00
ctx := kong.Parse(&CLI)
if ctx.Error != nil {
fail(ctx.Error)
}
cfg, err := config.Load(CLI.ConfigFile)
if err != nil {
fail(err)
}
p := tea.NewProgram(tui.New(cfg))
2024-03-17 09:10:05 +00:00
if _, err := p.Run(); err != nil {
2024-03-20 04:44:11 +00:00
fail(err)
2024-03-17 09:10:05 +00:00
}
}
2024-03-20 04:44:11 +00:00
func fail(err error) {
fmt.Printf("program error: %v\n", err)
os.Exit(1)
}