From ac024fff3ce70b435a39de83f7aa3339668fdc6b Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sun, 24 Nov 2024 02:59:00 -0500 Subject: Instant slider animation --- cmd/termpicker/flags.go | 13 ++++++++++++- cmd/termpicker/main.go | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/termpicker/flags.go b/cmd/termpicker/flags.go index f3cfd53..660c053 100644 --- a/cmd/termpicker/flags.go +++ b/cmd/termpicker/flags.go @@ -2,4 +2,15 @@ package main import "github.com/urfave/cli/v2" -var AppFlags []cli.Flag = []cli.Flag{} +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 index 0ebbadb..ef9f87f 100644 --- a/cmd/termpicker/main.go +++ b/cmd/termpicker/main.go @@ -14,6 +14,16 @@ import ( ) 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 {{{ r := slider.New('R', 255, progress.WithGradient("#660000", "#ff0000")) -- cgit v1.2.3