diff --git a/emojis/emoji.go b/emojis/emoji.go new file mode 100644 index 0000000..68a4a62 --- /dev/null +++ b/emojis/emoji.go @@ -0,0 +1,17 @@ +package emojis + +import ( + "fmt" + + "github.com/wzshiming/ctc" +) + +// CheckMarkColor ✔ emoji +func CheckMarkColor(color ctc.Color) string { + return fmt.Sprintf("%s%c%s ", color, '\u2714', ctc.Reset) +} + +// CheckMark green check mark +func CheckMark() string { + return CheckMarkColor(ctc.ForegroundGreen) +} diff --git a/krab/action_migrate_status.go b/krab/action_migrate_status.go index e10fe33..f958763 100644 --- a/krab/action_migrate_status.go +++ b/krab/action_migrate_status.go @@ -7,11 +7,11 @@ import ( "github.com/emirpasic/gods/sets/hashset" "github.com/ohkrab/krab/cli" "github.com/ohkrab/krab/cliargs" + "github.com/ohkrab/krab/emojis" "github.com/ohkrab/krab/krabdb" "github.com/ohkrab/krab/krabtpl" "github.com/ohkrab/krab/tpls" "github.com/pkg/errors" - "github.com/wzshiming/ctc" ) // ActionMigrateStatus keeps data needed to perform this action. @@ -100,7 +100,7 @@ func (a *ActionMigrateStatus) Do(ctx context.Context, db krabdb.DB, tpl *tpls.Te if pending { ui.Error(fmt.Sprint("- ", migration.Version, " ", migration.RefName)) } else { - ui.Output(fmt.Sprint(ctc.ForegroundGreen, "+ ", ctc.Reset, migration.Version, " ", migration.RefName)) + ui.Output(fmt.Sprint(emojis.CheckMark(), migration.Version, " ", migration.RefName)) } } diff --git a/spec/action_migrate_status_arguments_test.go b/spec/action_migrate_status_arguments_test.go index 0947510..6e84ee3 100644 --- a/spec/action_migrate_status_arguments_test.go +++ b/spec/action_migrate_status_arguments_test.go @@ -1,7 +1,10 @@ package spec import ( + "fmt" "testing" + + "github.com/ohkrab/krab/emojis" ) func TestActionMigrateStatusArguments(t *testing.T) { @@ -27,5 +30,5 @@ migration_set "animals" { c.AssertSuccessfulRun(t, []string{"migrate", "up", "animals", "-schema", "custom"}) c.AssertSuccessfulRun(t, []string{"migrate", "status", "animals", "-schema", "custom"}) - c.AssertOutputContains(t, "\x1b[0;32m+ \x1b[0mv1 create_animals") + c.AssertOutputContains(t, fmt.Sprint(emojis.CheckMark(), "v1 create_animals")) }