From d2fdcbc0d4f8b4c184ba2b1c3c4b00da3918521f Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Wed, 26 Mar 2025 17:28:58 -0400 Subject: Stylish `--help` + generate manpages (#27) * man page generation * generate VHS Gifs manually * goreleaser packages manpage --- internal/app/app.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/app/app.go (limited to 'internal/app/app.go') diff --git a/internal/app/app.go b/internal/app/app.go new file mode 100644 index 0000000..d0b168d --- /dev/null +++ b/internal/app/app.go @@ -0,0 +1,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 "}, + Version: version, + Flags: AppFlags, + EnableShellCompletion: true, + } + + return cmd +} -- cgit v1.2.3