diff --git a/vcr/mongo/create/create.go b/vcr/mongo/create/create.go index d54d14c..ee75bd7 100644 --- a/vcr/mongo/create/create.go +++ b/vcr/mongo/create/create.go @@ -50,16 +50,20 @@ func runCreate(ctx context.Context, opts *Options) error { return fmt.Errorf("failed to create database: %w", err) } fmt.Fprintf(io.Out, heredoc.Doc(` - %s Database created: - username: %s - password: %s - database: %s - connectionString: %s + %s Database created + %s username: %s + %s password: %s + %s database: %s + %s connectionString: %s `), c.SuccessIcon(), + c.Blue(cmdutil.InfoIcon), result.Username, + c.Blue(cmdutil.InfoIcon), result.Password, + c.Blue(cmdutil.InfoIcon), result.Database, + c.Blue(cmdutil.InfoIcon), result.ConnectionString) return nil } diff --git a/vcr/mongo/create/create_test.go b/vcr/mongo/create/create_test.go index 2fce887..e3898d0 100644 --- a/vcr/mongo/create/create_test.go +++ b/vcr/mongo/create/create_test.go @@ -50,11 +50,11 @@ func TestMongoCreate(t *testing.T) { }, want: want{ stdout: heredoc.Doc(` - ✓ Database created: - username: test - password: test - database: TestDB - connectionString: mongodb://test:test@localhost:27017/TestDB + ✓ Database created + ℹ username: test + ℹ password: test + ℹ database: TestDB + ℹ connectionString: mongodb://test:test@localhost:27017/TestDB `), }, }, diff --git a/vcr/mongo/info/info.go b/vcr/mongo/info/info.go index 8d2556a..b3e19bc 100644 --- a/vcr/mongo/info/info.go +++ b/vcr/mongo/info/info.go @@ -54,16 +54,20 @@ func runInfo(ctx context.Context, opts *Options) error { return fmt.Errorf("failed to get database info: %w", err) } fmt.Fprintf(io.Out, heredoc.Doc(` - %s Database info: - username: %s - password: %s - database: %s - connectionString: %s + %s Database info + %s username: %s + %s password: %s + %s database: %s + %s connectionString: %s `), c.SuccessIcon(), + c.Blue(cmdutil.InfoIcon), result.Username, + c.Blue(cmdutil.InfoIcon), result.Password, + c.Blue(cmdutil.InfoIcon), result.Database, + c.Blue(cmdutil.InfoIcon), result.ConnectionString) return nil } diff --git a/vcr/mongo/info/info_test.go b/vcr/mongo/info/info_test.go index 1752803..6f61512 100644 --- a/vcr/mongo/info/info_test.go +++ b/vcr/mongo/info/info_test.go @@ -52,11 +52,11 @@ func TestMongoInfo(t *testing.T) { }, want: want{ stdout: heredoc.Doc(` - ✓ Database info: - username: test - password: test - database: TestDB - connectionString: mongodb://test:test@localhost:27017/TestDB + ✓ Database info + ℹ username: test + ℹ password: test + ℹ database: TestDB + ℹ connectionString: mongodb://test:test@localhost:27017/TestDB `), }, }, diff --git a/vcr/mongo/list/list.go b/vcr/mongo/list/list.go index 903c0d9..98de919 100644 --- a/vcr/mongo/list/list.go +++ b/vcr/mongo/list/list.go @@ -6,6 +6,7 @@ import ( "vonage-cloud-runtime-cli/pkg/cmdutil" "github.com/MakeNowJust/heredoc" + "github.com/cli/cli/v2/utils" "github.com/spf13/cobra" ) @@ -43,7 +44,7 @@ func runList(ctx context.Context, opts *Options) error { io := opts.IOStreams() c := opts.IOStreams().ColorScheme() - spinner := cmdutil.DisplaySpinnerMessageWithHandle(" Creating Database") + spinner := cmdutil.DisplaySpinnerMessageWithHandle(" Listing Databases") result, err := opts.DeploymentClient().ListMongoDatabases(ctx, opts.Version) spinner.Stop() if err != nil { @@ -55,9 +56,17 @@ func runList(ctx context.Context, opts *Options) error { return nil } - fmt.Fprintf(io.Out, "%s Databases:\n", c.SuccessIcon()) + //nolint + tp := utils.NewTablePrinter(io) + tp.AddField(c.Bold("Database"), nil, nil) + tp.EndRow() for _, db := range result { - fmt.Fprintf(io.Out, " - %s\n", db) + tp.AddField(db, nil, nil) + tp.EndRow() + } + + if err := tp.Render(); err != nil { + return fmt.Errorf("error rending databases: %w", err) } return nil diff --git a/vcr/mongo/list/list_test.go b/vcr/mongo/list/list_test.go index 0fa9afc..bb5e61e 100644 --- a/vcr/mongo/list/list_test.go +++ b/vcr/mongo/list/list_test.go @@ -47,9 +47,9 @@ func TestMongoList(t *testing.T) { }, want: want{ stdout: heredoc.Doc(` - ✓ Databases: - - TestDB1 - - TestDB2 + Database + TestDB1 + TestDB2 `), }, },