Skip to content

Commit

Permalink
Add emoji to status
Browse files Browse the repository at this point in the history
  • Loading branch information
qbart committed Dec 5, 2021
1 parent b74411d commit 044a3f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
17 changes: 17 additions & 0 deletions emojis/emoji.go
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions krab/action_migrate_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
}

}
Expand Down
5 changes: 4 additions & 1 deletion spec/action_migrate_status_arguments_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package spec

import (
"fmt"
"testing"

"github.com/ohkrab/krab/emojis"
)

func TestActionMigrateStatusArguments(t *testing.T) {
Expand All @@ -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"))
}

0 comments on commit 044a3f3

Please sign in to comment.