summaryrefslogtreecommitdiff
path: root/internal/app
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin.chausse@goto.com>2025-03-26 17:21:12 -0400
committerBenjamin Chausse <benjamin.chausse@goto.com>2025-03-26 17:21:12 -0400
commit091c845c79b0aaf031e2fbbeaa91edb45d8d0272 (patch)
tree1f652e7951911f875ae2e218b29bd1a2a778d542 /internal/app
parentee994af6151654045e9a2543e360d2554fc4f851 (diff)
De-bloat + goreleaser packages manpage
Diffstat (limited to 'internal/app')
-rw-r--r--internal/app/app.go27
-rw-r--r--internal/app/description.txt23
-rw-r--r--internal/app/flags.go20
-rw-r--r--internal/app/keybindings.md24
4 files changed, 40 insertions, 54 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
index da19002..d0b168d 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -3,23 +3,16 @@ package app
import (
"context"
_ "embed"
- "fmt"
- "io"
"log/slog"
"github.com/ChausseBenjamin/termpicker/internal/logging"
"github.com/ChausseBenjamin/termpicker/internal/switcher"
tea "github.com/charmbracelet/bubbletea"
- "github.com/charmbracelet/glamour"
- docs "github.com/urfave/cli-docs/v3"
"github.com/urfave/cli/v3"
)
-//go:embed keybindings.md
-var KeybindingDocs string
-
-// Set by the build system
-var version = "compiled"
+//go:embed description.txt
+var Desc string
func AppAction(ctx context.Context, cmd *cli.Command) error {
logfile := logging.Setup(cmd.String("logfile"))
@@ -40,28 +33,18 @@ func AppAction(ctx context.Context, cmd *cli.Command) error {
return nil
}
-func Command() *cli.Command {
+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 <benjamin@chausse.xyz>"},
Version: version,
Flags: AppFlags,
EnableShellCompletion: true,
}
- cli.HelpPrinter = func(w io.Writer, _ string, _ any) {
- docs.MarkdownDocTemplate = fmt.Sprintf("%s\n‎\n\n%s",
- docs.MarkdownDocTemplate,
- KeybindingDocs,
- )
-
- helpRaw, _ := docs.ToMarkdown(cmd)
- helpCute, _ := glamour.Render(helpRaw, "auto")
-
- w.Write([]byte(helpCute))
- }
-
return cmd
}
diff --git a/internal/app/description.txt b/internal/app/description.txt
new file mode 100644
index 0000000..cf58bd6
--- /dev/null
+++ b/internal/app/description.txt
@@ -0,0 +1,23 @@
+Termpicker is a terminal-based application designed to help users select and manipulate colors efficiently. Its keybindings are meant to be intuitive to vim users as it behaves in a modal way:
+
+Normal mode:
+
+ - h,l: decrease/increase the current slider coarsely by 5%
+ - H,L: decrease/increase the current slider finely by 1
+ - j,k: select the slider below/above
+ - <Tab>,<S-Tab>: move to the next/previous tab
+ - f,b : copy the color as an ANSI foreground/background escape code
+ - x,r,s,c: copy the color as a hex, rgb, hsl, or cmyk value
+ - ?: expand/shrink the help menu
+ - i,<cmd>: enter Insert mode
+ - q,<C-c>: quit the application
+
+Insert mode:
+
+ Manually type a color. Pressing will cancel/leave insert mode. Anything in
+ the following formats will be used as a color input when pressing enter:
+
+ - Hex: #rrggbb
+ - RGB: rgb( r, g, b)
+ - CMYK: cmyk(c, m, y, k)
+ - HSL: hsl(h, s, l)
diff --git a/internal/app/flags.go b/internal/app/flags.go
index fae403b..7b3ab5a 100644
--- a/internal/app/flags.go
+++ b/internal/app/flags.go
@@ -3,19 +3,23 @@ package app
import "github.com/urfave/cli/v3"
const (
- flagLogfile = "logfile"
+ flagLogfile = "log-file"
)
var AppFlags []cli.Flag = []cli.Flag{
&cli.StringFlag{
- Name: flagLogfile,
- Aliases: []string{"l"},
- Usage: "Log file",
+ Name: "color",
+ Aliases: []string{"c"},
+ Usage: "Initial color",
+ Value: "",
+ DefaultText: "#b7416e",
},
&cli.StringFlag{
- Name: "color",
- Aliases: []string{"c"},
- Usage: "Initial color",
- Value: "",
+ Name: flagLogfile,
+ Aliases: []string{"l"},
+ Usage: "Log file",
+ Sources: cli.EnvVars("TERMPICKER_LOG_FILE"),
+ DefaultText: "/path/to/termpicker-logs.txt",
},
+ cli.VersionFlag,
}
diff --git a/internal/app/keybindings.md b/internal/app/keybindings.md
deleted file mode 100644
index 03f8201..0000000
--- a/internal/app/keybindings.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# KEYBINDINGS
-
-**Normal mode**:
-
-- `h`,`l`: coarse decrease/increase the current slider by 5%
-- `H`,`L`: fine decrease/increase the current slider by 1
-- `j`,`k`: select the slider below/above
-- `<Tab>`,`<S-Tab>`: move to the next/previous tab
-- `f`,`b`: copy the color as an ANSI escape code for the foreground/background
-- `x`,`r`,`s`,`c`: copy the color as a hex/rgb/hsl/cmyk
-- `?`: expand/shrink the help menu
-- `i`,`<cmd>`: enter Insert mode
-- `q`/`<C-c>`: quit the application
-
-**Insert mode**:
-
-Manually type a color. Pressing <Esc> will cancel/leave insert mode.
-Anything in the following formats will be used as a color input when
-pressing enter:
-
-- Hex values: `#rrggbb`
-- RGB values: `rgb( r, g, b)`
-- CMYK values: `cmyk(c, m, y, k)`
-- HSL values: `hsl(h, s, l)`