Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove indentation from chain serve output to make it easier to properly copy and paste #3522

Merged
merged 12 commits into from
Jul 20, 2023
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- [#3581](https://github.com/ignite/cli/pull/3581) Bump cometbft and cometbft-db in the template
- [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1`
- [#3522](https://github.com/ignite/cli/pull/3522) Remove indentation from `chain serve` output

## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0)

Expand Down
8 changes: 1 addition & 7 deletions ignite/pkg/cliui/view/accountview/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"fmt"
"strings"

"github.com/muesli/reflow/indent"
"github.com/muesli/reflow/wordwrap"

"github.com/ignite/cli/ignite/pkg/cliui/colors"
"github.com/ignite/cli/ignite/pkg/cliui/icons"
)
Expand Down Expand Up @@ -48,10 +45,7 @@ func (a Account) String() string {

// The account is new when the mnemonic is available
if a.Mnemonic != "" {
m := wordwrap.String(a.Mnemonic, 80)
m = indent.String(m, 2)

return fmt.Sprintf(fmtNewAccount, icons.OK, name, a.Address, colors.Mnemonic(m))
return fmt.Sprintf(fmtNewAccount, icons.OK, name, a.Address, colors.Mnemonic(a.Mnemonic))
}

return fmt.Sprintf(fmtExistingAccount, icons.User, name, a.Address)
Expand Down
36 changes: 36 additions & 0 deletions ignite/pkg/cliui/view/accountview/account_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package accountview_test

import (
"testing"

"github.com/ignite/cli/ignite/pkg/cliui/view/accountview"
"github.com/stretchr/testify/assert"
)

func TestAccountString(t *testing.T) {
tests := []struct {
name string
account accountview.Account
want string
}{
{
name: "new account (mnemonic available) to string is not idented",
account: accountview.NewAccount("alice", "cosmos193he38n21khnmb2", accountview.WithMnemonic("person estate daughter box chimney clay bronze ring story truck make excess ring frame desk start food leader sleep predict item rifle stem boy")),
want: "✔ Added account \x1b[1malice\x1b[0m with address cosmos193he38n21khnmb2 and mnemonic:\nperson estate daughter box chimney clay bronze ring story truck make excess ring frame desk start food leader sleep predict item rifle stem boy\n",
},
{
name: "existent account to string is not idented",
account: accountview.NewAccount("alice", "cosmos193he38n21khnmb2"),
want: "👤 \x1b[1malice\x1b[0m's account address: cosmos193he38n21khnmb2\n",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := tt.account.String()

assert.NotEmpty(t, result)
assert.Equal(t, tt.want, result)
})
}
}