Skip to content

Commit

Permalink
Adding logo to \copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Jan 16, 2024
1 parent 36d9aab commit 4d071aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 1 addition & 6 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"database/sql"
"errors"
"fmt"
"image/png"
"io"
"log"
"net/url"
Expand Down Expand Up @@ -229,11 +228,7 @@ func (h *Handler) Run() error {
if iactive {
// graphics logo
if typ := env.TermGraphics(); typ.Available() {
logo, err := png.Decode(bytes.NewReader(text.LogoPng))
if err != nil {
return err
}
if err := typ.Encode(stdout, logo); err != nil {
if err := typ.Encode(stdout, text.Logo); err != nil {
return err
}
}
Expand Down
3 changes: 3 additions & 0 deletions metacmd/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func init() {
Name: "copyright",
Desc: Desc{"show " + text.CommandName + " usage and distribution terms", ""},
Process: func(p *Params) error {
if typ := env.TermGraphics(); typ.Available() {
typ.Encode(p.Handler.IO().Stdout(), text.Logo)
}
p.Handler.Print(text.Copyright)
return nil
},
Expand Down
13 changes: 13 additions & 0 deletions text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
package text

import (
"bytes"
_ "embed"
"image"
"image/png"
"regexp"
"strings"
)
Expand Down Expand Up @@ -119,6 +122,9 @@ var CommandUpper = func() string {
return strings.ToUpper(Command())
}

// Logo is the logo.
var Logo image.Image

// LogoPng is the embedded logo.
//
//go:embed logo.png
Expand All @@ -139,3 +145,10 @@ Arguments:
Options:
{{.Context.Flags|FlagsToTwoColumns|FormatTwoColumns}}{{end}}`
}

func init() {
var err error
if Logo, err = png.Decode(bytes.NewReader(LogoPng)); err != nil {
panic(err)
}
}

0 comments on commit 4d071aa

Please sign in to comment.