okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

dawnadd charm tui skillf7fcae1

main
626 B27 linesraw
1package main
2
3import (
4	tea "charm.land/bubbletea/v2"
5	"context"
6	"fmt"
7	"github.com/charmbracelet/x/term"
8	"os"
9)
10
11func run() error {
12	if !term.IsTerminal(os.Stdin.Fd()) || !term.IsTerminal(os.Stderr.Fd()) {
13		return fmt.Errorf("search demo requires terminal stdin and stderr")
14	}
15	ctx, cancel := context.WithCancel(context.Background())
16	defer cancel()
17	m := newModel(ctx, demoSearch)
18	defer m.state.stop()
19	_, err := tea.NewProgram(m, tea.WithContext(ctx), tea.WithInput(os.Stdin), tea.WithOutput(os.Stderr)).Run()
20	return err
21}
22func main() {
23	if err := run(); err != nil {
24		fmt.Fprintln(os.Stderr, err)
25		os.Exit(1)
26	}
27}