36 lines
602 B
Go
36 lines
602 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"code.humancabbage.net/sam/moonmath/config"
|
|
"code.humancabbage.net/sam/moonmath/tui"
|
|
"github.com/alecthomas/kong"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
var CLI struct {
|
|
ConfigFile string `help:"Path to TOML configuration file."`
|
|
}
|
|
|
|
func main() {
|
|
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))
|
|
if _, err := p.Run(); err != nil {
|
|
fail(err)
|
|
}
|
|
}
|
|
|
|
func fail(err error) {
|
|
fmt.Printf("program error: %v\n", err)
|
|
os.Exit(1)
|
|
}
|