diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-11-25 21:44:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 21:44:11 -0500 |
commit | de7c6e9ab8bb4ab3af4557800cf92dd5ebddd2f8 (patch) | |
tree | e889022472615bf6ab06df37469eb3bffba8f4a3 /main.go | |
parent | 44456ebb15be6f2d9e981fd4093c48fc736d219a (diff) |
feat: Interactive input (#16)
* Refactor copy keybinds into single help entry
* Manually input color values at runtime
* Showcase input instead of clipboard in demo
* more vhs updates
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 29 |
1 files changed, 2 insertions, 27 deletions
@@ -4,10 +4,7 @@ import ( "log/slog" "os" - "github.com/ChausseBenjamin/termpicker/internal/colors" - "github.com/ChausseBenjamin/termpicker/internal/picker" "github.com/ChausseBenjamin/termpicker/internal/switcher" - "github.com/ChausseBenjamin/termpicker/internal/userinput" "github.com/ChausseBenjamin/termpicker/internal/util" tea "github.com/charmbracelet/bubbletea" "github.com/urfave/cli/v2" @@ -26,32 +23,10 @@ func AppAction(ctx *cli.Context) error { slog.Info("Starting Termpicker") - sw := switcher.New([]picker.Model{ - *picker.RGB(), - *picker.CMYK(), - *picker.HSL(), - }) + sw := switcher.New() if colorStr := ctx.String("color"); colorStr != "" { - color, err := userinput.ParseColor(colorStr) - if err != nil { - slog.Error("Failed to parse color", util.ErrKey, err) - sw.NewNotice(err.Error()) - } else { - pc := color.ToPrecise() - switch color.(type) { - case colors.RGB: - sw.UpdatePicker(0, pc) - sw.SetActive(0) - case colors.CMYK: - sw.UpdatePicker(1, pc) - sw.SetActive(1) - case colors.HSL: - sw.UpdatePicker(2, pc) - sw.SetActive(2) - } - sw.NewNotice("Color set to " + colorStr) - } + sw.NewNotice(sw.SetColorFromText(colorStr)) } p := tea.NewProgram(sw) |