Skip to content

Commit 680d0af

Browse files
authored
refactor: remove github.com/gookit/color (#4557)
1 parent 6a6412a commit 680d0af

File tree

10 files changed

+39
-22
lines changed

10 files changed

+39
-22
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
- [#4463](https://github.com/ignite/cli/pull/4463) Run `chain simulation` with any simulation test case
5959
- [#4533](https://github.com/ignite/cli/pull/4533) Promote GitHub codespace instead of Gitpod
6060
- [#4549](https://github.com/ignite/cli/pull/4549) Remove unused placeholder vars
61+
- [#4557](https://github.com/ignite/cli/pull/4557) Remove github.com/gookit/color
6162

6263
### Fixes
6364

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ require (
3636
github.com/goccy/go-yaml v1.15.23
3737
github.com/google/go-github/v48 v48.2.0
3838
github.com/google/go-querystring v1.1.0
39-
github.com/gookit/color v1.5.4
4039
github.com/hashicorp/go-hclog v1.6.3
4140
github.com/hashicorp/go-plugin v1.6.3
4241
github.com/iancoleman/strcase v0.3.0
@@ -446,7 +445,6 @@ require (
446445
github.com/vektra/mockery/v2 v2.46.0 // indirect
447446
github.com/xanzy/ssh-agent v0.3.3 // indirect
448447
github.com/xen0n/gosmopolitan v1.2.2 // indirect
449-
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
450448
github.com/yagipy/maintidx v1.0.0 // indirect
451449
github.com/yeya24/promlinter v0.3.0 // indirect
452450
github.com/ykadowak/zerologlint v0.1.5 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,6 @@ github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqE
968968
github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY=
969969
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
970970
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
971-
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
972-
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
973971
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
974972
github.com/gordonklaus/ineffassign v0.1.0 h1:y2Gd/9I7MdY1oEIt+n+rowjBNDcLQq3RsH5hwJd0f9s=
975973
github.com/gordonklaus/ineffassign v0.1.0/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0=
@@ -1742,8 +1740,6 @@ github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI
17421740
github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU=
17431741
github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg=
17441742
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
1745-
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
1746-
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
17471743
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
17481744
github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM=
17491745
github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk=

ignite/cmd/account_create.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ignitecmd
33
import (
44
"github.com/spf13/cobra"
55

6+
"github.com/ignite/cli/v29/ignite/pkg/cliui"
67
"github.com/ignite/cli/v29/ignite/pkg/cosmosaccount"
78
"github.com/ignite/cli/v29/ignite/pkg/errors"
89
)
@@ -19,7 +20,11 @@ func NewAccountCreate() *cobra.Command {
1920
}
2021

2122
func accountCreateHandler(cmd *cobra.Command, args []string) error {
22-
name := args[0]
23+
var (
24+
name = args[0]
25+
session = cliui.New(cliui.StartSpinnerWithText(statusCreating))
26+
)
27+
defer session.End()
2328

2429
ca, err := cosmosaccount.New(
2530
cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)),
@@ -34,6 +39,5 @@ func accountCreateHandler(cmd *cobra.Command, args []string) error {
3439
return errors.Errorf("unable to create account: %w", err)
3540
}
3641

37-
cmd.Printf("Account %q created, keep your mnemonic in a secret place:\n\n%s\n", name, mnemonic)
38-
return nil
42+
return session.Printf("Account %q created, keep your mnemonic in a secret place:\n\n%s\n", name, mnemonic)
3943
}

ignite/cmd/account_delete.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ignitecmd
33
import (
44
"github.com/spf13/cobra"
55

6+
"github.com/ignite/cli/v29/ignite/pkg/cliui"
67
"github.com/ignite/cli/v29/ignite/pkg/cosmosaccount"
78
)
89

@@ -18,7 +19,11 @@ func NewAccountDelete() *cobra.Command {
1819
}
1920

2021
func accountDeleteHandler(cmd *cobra.Command, args []string) error {
21-
name := args[0]
22+
var (
23+
name = args[0]
24+
session = cliui.New(cliui.StartSpinnerWithText(statusDeleting))
25+
)
26+
defer session.End()
2227

2328
ca, err := cosmosaccount.New(
2429
cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)),
@@ -32,6 +37,5 @@ func accountDeleteHandler(cmd *cobra.Command, args []string) error {
3237
return err
3338
}
3439

35-
cmd.Printf("Account %s deleted.\n", name)
36-
return nil
40+
return session.Printf("Account %s deleted.\n", name)
3741
}

ignite/cmd/account_export.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/spf13/cobra"
99

10+
"github.com/ignite/cli/v29/ignite/pkg/cliui"
1011
"github.com/ignite/cli/v29/ignite/pkg/cosmosaccount"
1112
"github.com/ignite/cli/v29/ignite/pkg/errors"
1213
)
@@ -27,9 +28,11 @@ func NewAccountExport() *cobra.Command {
2728

2829
func accountExportHandler(cmd *cobra.Command, args []string) error {
2930
var (
30-
name = args[0]
31-
path = flagGetPath(cmd)
31+
name = args[0]
32+
path = flagGetPath(cmd)
33+
session = cliui.New(cliui.StartSpinnerWithText(statusExporting))
3234
)
35+
defer session.End()
3336

3437
passphrase, err := getPassphrase(cmd)
3538
if err != nil {
@@ -65,6 +68,5 @@ func accountExportHandler(cmd *cobra.Command, args []string) error {
6568
return err
6669
}
6770

68-
cmd.Printf("Account %q exported to file: %s\n", name, path)
69-
return nil
71+
return session.Printf("Account %q exported to file: %s\n", name, path)
7072
}

ignite/cmd/account_import.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/cosmos/go-bip39"
77
"github.com/spf13/cobra"
88

9+
"github.com/ignite/cli/v29/ignite/pkg/cliui"
910
"github.com/ignite/cli/v29/ignite/pkg/cliui/cliquiz"
1011
"github.com/ignite/cli/v29/ignite/pkg/cosmosaccount"
1112
"github.com/ignite/cli/v29/ignite/pkg/errors"
@@ -31,7 +32,9 @@ func accountImportHandler(cmd *cobra.Command, args []string) error {
3132
var (
3233
name = args[0]
3334
secret, _ = cmd.Flags().GetString(flagSecret)
35+
session = cliui.New(cliui.StartSpinnerWithText(statusImporting))
3436
)
37+
defer session.End()
3538

3639
if secret == "" {
3740
if err := cliquiz.Ask(
@@ -70,6 +73,5 @@ func accountImportHandler(cmd *cobra.Command, args []string) error {
7073
return err
7174
}
7275

73-
cmd.Printf("Account %q imported.\n", name)
74-
return nil
76+
return session.Printf("Account %q imported.\n", name)
7577
}

ignite/cmd/cmd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ const (
4242
cacheFileName = "ignite_cache.db"
4343

4444
statusGenerating = "Generating..."
45-
statusQuerying = "Querying..."
45+
statusImporting = "Importing..."
46+
statusExporting = "Exporting..."
47+
statusCreating = "Creating..."
48+
statusDeleting = "Deleting..."
4649
)
4750

4851
// List of CLI level one commands that should not load Ignite app instances.

ignite/pkg/cliui/clispinner/simple.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import (
88
"time"
99

1010
"github.com/briandowns/spinner"
11-
"github.com/gookit/color"
11+
12+
"github.com/ignite/cli/v29/ignite/pkg/cliui/colors"
1213
)
1314

1415
var (
1516
simpleCharset = spinner.CharSets[4]
1617
simpleRefreshRate = time.Millisecond * 300
17-
simpleColor = color.Blue
18+
simpleColor = colors.Spinner
1819
)
1920

2021
type SimpleSpinner struct {
@@ -115,7 +116,7 @@ func (s *SimpleSpinner) Start() Spinner {
115116
case <-ticker.C: // Update the spinner on each tick
116117
s.mu.Lock()
117118
frame := charset[index]
118-
str := fmt.Sprintf("\r%s%s %s", prefix, simpleColor.Sprint(frame), text)
119+
str := fmt.Sprintf("\r%s%s %s", prefix, simpleColor(frame), text)
119120
_, _ = fmt.Fprint(writer, str) // Update the spinner in the same line
120121
index++
121122
if index >= len(charset) {

ignite/pkg/cliui/colors/colors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
Cyan = "#34e2e2"
1515
White = "#FFFFFF"
1616
HiBlue = "#729FCF"
17+
Blue = "#0a2fc4"
1718
)
1819

1920
var (
@@ -24,6 +25,7 @@ var (
2425
modified = lipgloss.NewStyle().Foreground(lipgloss.Color(Magenta))
2526
name = lipgloss.NewStyle().Bold(true)
2627
mnemonic = lipgloss.NewStyle().Foreground(lipgloss.Color(HiBlue))
28+
spinner = lipgloss.NewStyle().Foreground(lipgloss.Color(Blue))
2729
faint = lipgloss.NewStyle().Faint(true)
2830
)
2931

@@ -65,6 +67,10 @@ func Mnemonic(i ...interface{}) string {
6567
return mnemonic.Render(fmt.Sprint(i...))
6668
}
6769

70+
func Spinner(i ...interface{}) string {
71+
return spinner.Render(fmt.Sprint(i...))
72+
}
73+
6874
// Faint styles the text using a dimmer shade for the foreground color.
6975
func Faint(i ...interface{}) string {
7076
return faint.Render(fmt.Sprint(i...))

0 commit comments

Comments
 (0)