Skip to content

Commit

Permalink
Replace fatih/color with gookit/color (#390)
Browse files Browse the repository at this point in the history
* Replace `fatih/color` with `gookit/color`

* Update docs/changelog.md
  • Loading branch information
waybackarchiver authored May 20, 2023
1 parent 33e5522 commit aacbef2
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improve context deadline ([#381](https://github.com/wabarc/wayback/pull/381))
- Improve publish services ([#382](https://github.com/wabarc/wayback/pull/382))
- Refactor and reorganize service entry ([#389](https://github.com/wabarc/wayback/pull/389))
- Replace `fatih/color` with `gookit/color` ([#390](https://github.com/wabarc/wayback/pull/390))

## [0.19.1] - 2023-03-21

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ require (
github.com/dghubble/oauth1 v0.7.1
github.com/dstotijn/go-notion v0.11.0
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.15.0
github.com/gabriel-vasile/mimetype v1.4.2
github.com/go-shiori/go-readability v0.0.0-20220215145315-dd6828d2f09b
github.com/go-shiori/obelisk v0.0.0-20221119111008-23c015a8fad7
github.com/google/go-github/v40 v40.0.0
github.com/gookit/color v1.5.3
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/hashicorp/go-version v1.6.0
Expand Down Expand Up @@ -81,6 +81,7 @@ require (
github.com/dghubble/sling v1.3.0 // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dop251/goja v0.0.0-20221115122301-6c0d9883792e // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/go-shiori/dom v0.0.0-20210627111528-4e4722cd0d65 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
Expand Down Expand Up @@ -148,6 +149,7 @@ require (
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
github.com/wabarc/memento v0.0.0-20210703205719-adc2f8ab8bae // indirect
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
github.com/ybbus/httpretry v1.0.1 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gookit/color v1.5.3 h1:twfIhZs4QLCtimkP7MOxlF3A0U/5cDPseRT9M/+2SCE=
github.com/gookit/color v1.5.3/go.mod h1:NUzwzeehUfl7GIb36pqId+UGmRfQcU/WiiyTTeNjHtE=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
Expand Down Expand Up @@ -647,6 +649,8 @@ github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c/go.mod h1:
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b h1:wA3QeTsaAXybLL2kb2cKhCAQTHgYTMwuI8lBlJSv5V8=
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b/go.mod h1:xT1Y5p2JR2PfSZihE0s4mjdJaRGp1waCTf5JzhQLBck=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/ybbus/httpretry v1.0.1 h1:lpo0rx/qY4kvishWD6kDgEFW7uGzx4gB/9AgPO5rg9Q=
github.com/ybbus/httpretry v1.0.1/go.mod h1:Md7FpyqeEX8F0pOnH0KN4MW1ek3cypGJmbtCNJSJMZg=
Expand Down
6 changes: 3 additions & 3 deletions service/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strconv"
"strings"

"github.com/fatih/color"
"github.com/gookit/color"
"github.com/wabarc/helper"
"github.com/wabarc/logger"
"github.com/wabarc/wayback"
Expand Down Expand Up @@ -81,11 +81,11 @@ func (d *Discord) Serve() (err error) {
return errors.New("Initialize discord failed, error: %v", err)
}
d.bot.AddHandler(func(s *discord.Session, _ *discord.Ready) {
logger.Info("authorized on account %s", color.BlueString(s.State.User.Username))
logger.Info("authorized on account %s", color.Blue.Sprint(s.State.User.Username))
})

if channel, err := d.bot.UserChannelCreate(d.opts.DiscordChannel()); err == nil {
logger.Info("channel name: %s, channel id: %s", color.BlueString(channel.Name), color.BlueString(channel.ID))
logger.Info("channel name: %s, channel id: %s", color.Blue.Sprint(channel.Name), color.Blue.Sprint(channel.ID))
}

commandHandlers := d.commandHandlers()
Expand Down
4 changes: 2 additions & 2 deletions service/httpd/httpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/cretz/bine/tor"
"github.com/fatih/color"
"github.com/gookit/color"
"github.com/wabarc/logger"
"github.com/wabarc/wayback/config"
"github.com/wabarc/wayback/errors"
Expand Down Expand Up @@ -116,7 +116,7 @@ func (h *Httpd) Shutdown() error {
}

func startHTTPServer(server *http.Server) {
logger.Info(`Listening on "%s" without TLS`, color.BlueString(server.Addr))
logger.Info(`Listening on "%s" without TLS`, color.Blue.Sprint(server.Addr))
if err := server.ListenAndServe(); err != http.ErrServerClosed {
logger.Fatal("Server failed to start: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions service/httpd/onion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/cretz/bine/tor"
"github.com/cretz/bine/torutil/ed25519"
"github.com/fatih/color"
"github.com/gookit/color"
"github.com/wabarc/logger"
"github.com/wabarc/wayback/errors"
)
Expand All @@ -27,7 +27,7 @@ func (h *Httpd) startOnionService(server *http.Server) error {
} else {
pvk = keypair.PrivateKey()
}
logger.Info("important to keep the private key: %s", color.BlueString(hex.EncodeToString(pvk)))
logger.Info("important to keep the private key: %s", color.Blue.Sprint(hex.EncodeToString(pvk)))
} else {
privb, err := hex.DecodeString(h.opts.OnionPrivKey())
if err != nil {
Expand Down Expand Up @@ -73,7 +73,7 @@ func (h *Httpd) startOnionService(server *http.Server) error {
}
onion.CloseLocalListenerOnClose = true

logger.Info(`listening on "%s" without TLS`, color.BlueString(onion.LocalListener.Addr().String()))
logger.Info(`listening on "%s" without TLS`, color.Blue.Sprint(onion.LocalListener.Addr().String()))
logger.Info("please open a Tor capable browser and navigate to http://%v.onion", onion.ID)

go func() {
Expand Down
7 changes: 4 additions & 3 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"net/url"

"github.com/gookit/color"
"github.com/wabarc/logger"
"github.com/wabarc/wayback"
"github.com/wabarc/wayback/config"
Expand Down Expand Up @@ -73,11 +74,11 @@ func Shutdown() (errs error) {
return errors.New("module not found")
}

logger.Info("stopping %s service...", flag)
logger.Info("stopping %s service...", color.Blue.Sprint(flag))
if err = mod.Shutdown(); err != nil {
errs = fmt.Errorf("shutdown %s failed: %w", flag, err)
errs = fmt.Errorf("shutdown %s failed: %w", color.Red.Sprint(flag), err)
}
logger.Info("stopped %s service", flag)
logger.Info("stopped %s service", color.Cyan.Sprint(flag))
}

return
Expand Down
4 changes: 2 additions & 2 deletions service/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"net/url"

"github.com/fatih/color"
"github.com/gookit/color"
"github.com/slack-go/slack"
"github.com/slack-go/slack/slackevents"
"github.com/slack-go/slack/socketmode"
Expand Down Expand Up @@ -115,7 +115,7 @@ func (s *Slack) Serve() (err error) {
if err != nil {
return err
}
logger.Info("authorized on account %s", color.BlueString(user.User))
logger.Info("authorized on account %s", color.Blue.Sprint(user.User))

go func() {
for evt := range s.client.Events {
Expand Down
6 changes: 3 additions & 3 deletions service/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"time"

"github.com/fatih/color"
"github.com/gookit/color"
"github.com/wabarc/helper"
"github.com/wabarc/logger"
"github.com/wabarc/wayback"
Expand Down Expand Up @@ -94,11 +94,11 @@ func (t *Telegram) Serve() (err error) {
if t.bot == nil {
return errors.New("Initialize telegram failed, error: %v", err)
}
logger.Info("authorized on account %s", color.BlueString(t.bot.Me.Username))
logger.Info("authorized on account %s", color.Blue.Sprint(t.bot.Me.Username))

if channel, err := t.bot.ChatByUsername(t.opts.TelegramChannel()); err == nil {
id := strconv.FormatInt(channel.ID, 10)
logger.Info("channel title: %s, channel id: %s", color.BlueString(channel.Title), color.BlueString(id))
logger.Info("channel title: %s, channel id: %s", color.Blue.Sprint(channel.Title), color.Blue.Sprint(id))
}

// Set bot commands
Expand Down

0 comments on commit aacbef2

Please sign in to comment.