blob: d0b168ddec9cae30766fb6e1bdc629103a3d73f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package app
import (
"context"
_ "embed"
"log/slog"
"github.com/ChausseBenjamin/termpicker/internal/logging"
"github.com/ChausseBenjamin/termpicker/internal/switcher"
tea "github.com/charmbracelet/bubbletea"
"github.com/urfave/cli/v3"
)
//go:embed description.txt
var Desc string
func AppAction(ctx context.Context, cmd *cli.Command) error {
logfile := logging.Setup(cmd.String("logfile"))
defer logfile.Close()
slog.Info("Starting Termpicker")
sw := switcher.New()
if colorStr := cmd.String("color"); colorStr != "" {
sw.NewNotice(sw.SetColorFromText(colorStr))
}
p := tea.NewProgram(sw)
if _, err := p.Run(); err != nil {
return err
}
return nil
}
func Command(version string) *cli.Command {
cmd := &cli.Command{
Name: "termpicker",
Usage: "A terminal-based color picker",
Action: AppAction,
ArgsUsage: "",
Description: Desc,
Authors: []any{"Benjamin Chausse <benjamin@chausse.xyz>"},
Version: version,
Flags: AppFlags,
EnableShellCompletion: true,
}
return cmd
}
|