Commit 4d21fda

Karn Wong <[email protected]>
2024-03-19 12:22:26
get ip: add color
1 parent f1a62c1
Changed files (1)
cmd
cmd/get/get_ip.go
@@ -8,6 +8,8 @@ import (
 	"net/http"
 	"strings"
 
+	"github.com/fatih/color"
+
 	"github.com/spf13/cobra"
 )
 
@@ -63,17 +65,19 @@ var getIPCmd = &cobra.Command{
 	Short: "Get IP information",
 	Long:  `Get IP information`,
 	Run: func(cmd *cobra.Command, args []string) {
+		green := color.New(color.FgGreen).SprintFunc()
+
 		localIP, err := getLocalIP()
 		if err != nil {
 			fmt.Println(err)
 		}
-		fmt.Printf("Local IP   : %s\n", localIP)
+		fmt.Printf("Local IP   : %s\n", green(localIP))
 
 		publicIP, err := getPublicIP()
 		if err != nil {
 			fmt.Println(err)
 		}
-		fmt.Printf("Public IP  : %s\n", publicIP)
+		fmt.Printf("Public IP  : %s\n", green(publicIP))
 	},
 }