From 6cf75f9745ae628746b2357cbc040317e3564d77 Mon Sep 17 00:00:00 2001 From: Laura Date: Wed, 13 Aug 2025 22:03:17 +0200 Subject: [PATCH] fixes and cleanup --- cmd/ffwebp/banner.go | 43 +++++++++++++++++++++++++++++++++------- cmd/ffwebp/main.go | 2 +- internal/codec/detect.go | 2 -- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/cmd/ffwebp/banner.go b/cmd/ffwebp/banner.go index d70fbfd..101f2ce 100644 --- a/cmd/ffwebp/banner.go +++ b/cmd/ffwebp/banner.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "runtime" "sort" "strings" @@ -10,22 +11,53 @@ import ( "github.com/coalaura/ffwebp/internal/logx" ) -func banner() { +func codecList() []string { codecs := codec.All() names := make([]string, len(codecs)) for i, c := range codecs { names[i] = c.String() + + if !c.CanEncode() { + names[i] += "*" + } } sort.Strings(names) + return names +} + +func tags() string { + var ( + codec = "none" + feature = "none" + ) + if effects.HasEffects() { - names = append(names, "effects") + feature = "effects" } - build := strings.Join(names, ",") + codecs := codecList() + + if len(codecs) > 0 { + codec = strings.Join(codecs, " ") + } + + return fmt.Sprintf("[codecs: %s] [features: %s]", codec, feature) +} + +func banner() { + tags := codecList() + + if effects.HasEffects() { + tags = append(tags, "effects") + } + + if len(tags) == 0 { + tags = []string{"none"} + } logx.Printf("ffwebp version %s\n", Version) logx.Printf( @@ -34,8 +66,5 @@ func banner() { runtime.Version(), runtime.GOARCH, ) - logx.Printf( - " configuration: -tags %s\n", - build, - ) + logx.Printf(" %s\n", strings.Join(tags, ",")) } diff --git a/cmd/ffwebp/main.go b/cmd/ffwebp/main.go index 4ad3a93..49fd60c 100644 --- a/cmd/ffwebp/main.go +++ b/cmd/ffwebp/main.go @@ -96,7 +96,7 @@ func main() { app := &cli.Command{ Name: "ffwebp", Usage: "Convert any image format into any other image format", - Version: Version, + Version: fmt.Sprintf("%s %s", Version, tags()), Flags: flags, Action: run, Writer: os.Stderr, diff --git a/internal/codec/detect.go b/internal/codec/detect.go index f36a58e..41ff54a 100644 --- a/internal/codec/detect.go +++ b/internal/codec/detect.go @@ -87,8 +87,6 @@ func Sniff(reader io.Reader, input, force string, ignoreExtension bool) (*Sniffe return nil, nil, err } - fmt.Println(codec.String(), confidence) - if confidence <= 0 { continue }