feat: glint entrypoint (path / --daily / picker) and Start wiring
87bf7725a2ecff6baf01a6f7651051dd2fadff56
humdrum-tiv <45084903+humdrum-tiv@users.noreply.github.com> · 2026-06-27 22:21
parent 4608e5cf
3 files changed
internal/app/app.go +17 −0
@@ -64,6 +64,23 @@ a.status = path
return nil
}
+// Start picks the initial view: an explicit path, today's daily note, or the
+// picker when neither is given.
+func (a *App) Start(path string, daily bool) error {
+ switch {
+ case path != "":
+ return a.Load(path)
+ case daily:
+ _, cmd := a.openDaily()
+ _ = cmd
+ return nil
+ default:
+ _, cmd := a.openPicker()
+ _ = cmd
+ return nil
+ }
+}
+
func (a *App) Init() tea.Cmd { return nil }
// Update routes messages. Global keys are handled first, then mode-specific.
internal/app/app_test.go +43 −0
@@ -176,3 +176,46 @@ if _, err := os.Stat(a.path); err != nil {
t.Errorf("daily file should exist on disk: %v", err)
}
}
+
+func TestStartInPickerWhenNoPath(t *testing.T) {
+ dir := t.TempDir()
+ os.WriteFile(filepath.Join(dir, "n.md"), []byte("x"), 0o644)
+ cfg := config.Default()
+ cfg.VaultDir = dir
+ a := New(cfg)
+ if err := a.Start("", false); err != nil {
+ t.Fatal(err)
+ }
+ if a.mode != ModePicker {
+ t.Errorf("no path/daily should start in picker, mode = %d", a.mode)
+ }
+}
+
+func TestStartWithPathLoadsFile(t *testing.T) {
+ dir := t.TempDir()
+ p := filepath.Join(dir, "n.md")
+ os.WriteFile(p, []byte("hello"), 0o644)
+ a := New(config.Default())
+ if err := a.Start(p, false); err != nil {
+ t.Fatal(err)
+ }
+ if a.mode != ModeEditor || string(a.editor.Bytes()) != "hello" {
+ t.Errorf("Start(path) should load file into editor")
+ }
+}
+
+func TestStartDailyCreatesFile(t *testing.T) {
+ dir := t.TempDir()
+ cfg := config.Default()
+ cfg.VaultDir = dir
+ a := New(cfg)
+ if err := a.Start("", true); err != nil {
+ t.Fatal(err)
+ }
+ if a.mode != ModeEditor || a.path == "" {
+ t.Errorf("Start(daily) should open the daily note")
+ }
+ if _, err := os.Stat(a.path); err != nil {
+ t.Errorf("daily file should exist: %v", err)
+ }
+}
main.go +39 −0
@@ -0,0 +1,39 @@
+// Command glint is a modeless terminal markdown editor with live styling.
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+
+ "glint/internal/app"
+ "glint/internal/config"
+
+ tea "github.com/charmbracelet/bubbletea"
+)
+
+func main() {
+ daily := flag.Bool("daily", false, "open today's daily note")
+ flag.Parse()
+
+ cfg, err := config.Load()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "glint: config:", err)
+ }
+
+ var path string
+ if args := flag.Args(); len(args) > 0 {
+ path = args[0]
+ }
+
+ a := app.New(cfg)
+ if err := a.Start(path, *daily); err != nil {
+ fmt.Fprintln(os.Stderr, "glint:", err)
+ os.Exit(1)
+ }
+
+ if _, err := tea.NewProgram(a, tea.WithAltScreen()).Run(); err != nil {
+ fmt.Fprintln(os.Stderr, "glint:", err)
+ os.Exit(1)
+ }
+}