summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2025-01-16 00:20:12 -0500
committerGitHub <noreply@github.com>2025-01-16 00:20:12 -0500
commit7d2afe1ca176d0eb76f65523ed7ebcbca702d0c1 (patch)
tree148d0f8da77686ff7d713d8a233b3545b7994e2a /main.go
parentf438213c56fb072bbd3dc1aed0fd7e901181a7b9 (diff)
Central UI (#26)
* migrate to urfave/cli V3 * Remove slider background * Force the use of TrueColor everywhere * All ui info in one location * Fix BinaryFill Example * Make unfocused tabs more faint * Fix color input width * Ctrl-c overrides color input and quits termpicker * docs: remove redundant comment * fix: refactor picker View()
Diffstat (limited to 'main.go')
-rw-r--r--main.go37
1 files changed, 16 insertions, 21 deletions
diff --git a/main.go b/main.go
index 5511ac6..f8dacf8 100644
--- a/main.go
+++ b/main.go
@@ -1,31 +1,29 @@
package main
import (
+ "context"
"log/slog"
"os"
- "time"
"github.com/ChausseBenjamin/termpicker/internal/logging"
"github.com/ChausseBenjamin/termpicker/internal/switcher"
"github.com/ChausseBenjamin/termpicker/internal/util"
tea "github.com/charmbracelet/bubbletea"
- "github.com/urfave/cli/v2"
+ "github.com/urfave/cli/v3"
)
-var ( // Set by the build system
- version = "compiled"
- date = ""
-)
+// Set by the build system
+var version = "compiled"
-func AppAction(ctx *cli.Context) error {
- logfile := logging.Setup(ctx.String("logfile"))
+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 := ctx.String("color"); colorStr != "" {
+ if colorStr := cmd.String("color"); colorStr != "" {
sw.NewNotice(sw.SetColorFromText(colorStr))
}
@@ -37,19 +35,16 @@ func AppAction(ctx *cli.Context) error {
}
func main() {
- compileDate, _ := time.Parse(time.RFC3339, date)
- app := &cli.App{
- Name: "Termpicker",
- Usage: "A terminal-based color picker",
- Action: AppAction,
- Authors: []*cli.Author{
- {Name: "Benjamin Chausse", Email: "benjamin@chausse.xyz"},
- },
- Version: version,
- Flags: AppFlags,
- Compiled: compileDate,
+ app := &cli.Command{
+ Name: "Termpicker",
+ Usage: "A terminal-based color picker",
+ Action: AppAction,
+ Authors: []any{"Benjamin Chausse <benjamin@chausse.xhz>"},
+ Version: version,
+ Flags: AppFlags,
+ EnableShellCompletion: true,
}
- if err := app.Run(os.Args); err != nil {
+ if err := app.Run(context.Background(), os.Args); err != nil {
slog.Error("Program crashed", util.ErrKey, err.Error())
os.Exit(1)
}