@@ -11,7 +11,6 @@ import (
11
11
_ "image/jpeg"
12
12
_ "image/png"
13
13
"io"
14
- "math"
15
14
"os"
16
15
"path/filepath"
17
16
"regexp"
@@ -22,10 +21,9 @@ import (
22
21
_ "golang.org/x/image/tiff"
23
22
_ "golang.org/x/image/webp"
24
23
24
+ "github.com/kenshaw/colors"
25
25
"github.com/kenshaw/rasterm"
26
26
"github.com/spf13/cobra"
27
- "github.com/spf13/pflag"
28
- "gopkg.in/go-playground/colors.v1"
29
27
)
30
28
31
29
var (
@@ -41,20 +39,19 @@ func main() {
41
39
}
42
40
43
41
func run (ctx context.Context , appName , appVersion string , cliargs []string ) error {
44
- var bg colors. Color = colors .FromStdColor (color .Transparent )
42
+ bg : = colors .FromColor (color .Transparent )
45
43
c := & cobra.Command {
46
44
Use : appName + " [flags] <image1> [image2, ..., imageN]" ,
47
45
Short : appName + ", a command-line image viewer using terminal graphics" ,
48
46
Version : appVersion ,
49
47
RunE : func (cmd * cobra.Command , args []string ) error {
50
- bgColor := convColor (bg )
51
48
return do (os .Stdout , & Params {
52
- BG : bgColor ,
49
+ BG : bg ,
53
50
Args : args ,
54
51
})
55
52
},
56
53
}
57
- c .Flags ().Var (NewColor ( & bg ), "bg" , "background color" )
54
+ c .Flags ().Var (bg . Pflag ( ), "bg" , "background color" )
58
55
c .SetVersionTemplate ("{{ .Name }} {{ .Version }}\n " )
59
56
c .InitDefaultHelpCmd ()
60
57
c .SetArgs (cliargs [1 :])
@@ -136,38 +133,6 @@ func renderFile(w io.Writer, file string) error {
136
133
return rasterm .Encode (w , img )
137
134
}
138
135
139
- type Color struct {
140
- c * colors.Color
141
- }
142
-
143
- func NewColor (c * colors.Color ) pflag.Value {
144
- return Color {
145
- c : c ,
146
- }
147
- }
148
-
149
- func (c Color ) String () string {
150
- return (* c .c ).String ()
151
- }
152
-
153
- func (c Color ) Set (s string ) error {
154
- clr , err := colors .Parse (s )
155
- if err != nil {
156
- return colors .ErrBadColor
157
- }
158
- * c .c = clr
159
- return nil
160
- }
161
-
162
- func (c Color ) Type () string {
163
- return "color"
164
- }
165
-
166
- func convColor (c colors.Color ) color.Color {
167
- clr := c .ToRGBA ()
168
- return color.RGBA {R : clr .R , G : clr .G , B : clr .B , A : uint8 (math .Round (255 * clr .A ))}
169
- }
170
-
171
136
/*
172
137
func init() {
173
138
"github.com/klippa-app/go-libheif"
0 commit comments