Skip to content

Commit 0b255fe

Browse files
committed
chore(cmd): Refactor console output with color package integration.
- Add the `github.com/fatih/color` package import to `cmd/config.go` - Replace `fmt.Println` with `color.Green` in `cmd/config.go` - Change the error message in `git/git.go` when there are no differences to "please add your staged changes using git add <files...>"
1 parent 71a6dcd commit 0b255fe

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cmd/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package cmd
22

33
import (
44
"errors"
5-
"fmt"
65
"strings"
76

87
"github.com/appleboy/com/array"
8+
"github.com/fatih/color"
99
"github.com/spf13/cobra"
1010
"github.com/spf13/viper"
1111
)
@@ -42,7 +42,7 @@ var configCmd = &cobra.Command{
4242
if err := viper.WriteConfig(); err != nil {
4343
return err
4444
}
45-
fmt.Println("you can see the config file:", viper.ConfigFileUsed())
45+
color.Green("you can see the config file: %s", viper.ConfigFileUsed())
4646
return nil
4747
},
4848
}

git/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func Diff() (string, error) {
7777
log.Fatal(err)
7878
}
7979
if string(output) == "" {
80-
return "", errors.New("nothing output")
80+
return "", errors.New("please add your staged changes using git add <files...>")
8181
}
8282

8383
output, err = diffFiles().Output()

0 commit comments

Comments
 (0)