summaryrefslogtreecommitdiff
path: root/cmd/termpicker
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-11-25 15:17:02 -0500
committerGitHub <noreply@github.com>2024-11-25 15:17:02 -0500
commitfe46976256aa3a5cac9baf745ac1debcb49d00c0 (patch)
treefa093a584b6990827fbb1bed37feccc3958ab71f /cmd/termpicker
parent6981c08b60cccc7454038bb21391bd585a133684 (diff)
fix: enhance readme, and update notice duration (#12)
* Move main.go to root for easy go install ... * Better README * elongate notice duration
Diffstat (limited to 'cmd/termpicker')
-rw-r--r--cmd/termpicker/flags.go16
-rw-r--r--cmd/termpicker/main.go48
2 files changed, 0 insertions, 64 deletions
diff --git a/cmd/termpicker/flags.go b/cmd/termpicker/flags.go
deleted file mode 100644
index 660c053..0000000
--- a/cmd/termpicker/flags.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package main
-
-import "github.com/urfave/cli/v2"
-
-const (
- flagLogfile = "logfile"
-)
-
-var AppFlags []cli.Flag = []cli.Flag{
- &cli.StringFlag{
- Name: flagLogfile,
- Aliases: []string{"l"},
- Usage: "Log file",
- Value: "/dev/null", // Don't log by default
- },
-}
diff --git a/cmd/termpicker/main.go b/cmd/termpicker/main.go
deleted file mode 100644
index 241adcf..0000000
--- a/cmd/termpicker/main.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package main
-
-import (
- "log/slog"
- "os"
-
- "github.com/ChausseBenjamin/termpicker/internal/picker"
- "github.com/ChausseBenjamin/termpicker/internal/switcher"
- "github.com/ChausseBenjamin/termpicker/internal/util"
- tea "github.com/charmbracelet/bubbletea"
- "github.com/urfave/cli/v2"
-)
-
-func AppAction(ctx *cli.Context) error {
- logFile, err := os.Create(ctx.String(flagLogfile))
- if err != nil {
- slog.Error("Failed to create log file", util.ErrKey, err.Error())
- os.Exit(1)
- }
- defer logFile.Close()
-
- handler := slog.NewJSONHandler(logFile, nil)
- slog.SetDefault(slog.New(handler))
-
- slog.Info("Starting Termpicker")
- rgb := picker.RGB()
- cmyk := picker.CMYK()
- hsl := picker.HSL()
- sw := switcher.New([]picker.Model{*rgb, *cmyk, *hsl})
- p := tea.NewProgram(sw)
- if _, err := p.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func main() {
- app := &cli.App{
- Name: "TermPicker",
- Usage: "A terminal-based color picker",
- Action: AppAction,
- Flags: AppFlags,
- }
- if err := app.Run(os.Args); err != nil {
- slog.Error("Program crashed", util.ErrKey, err.Error())
- os.Exit(1)
- }
-}