Skip to content

Commit

Permalink
Merge pull request #1257 from vinicel/fix/colored-text-windows
Browse files Browse the repository at this point in the history
fix: colored text on windows
  • Loading branch information
sundowndev authored May 2, 2023
2 parents 4259f35 + b46b1b9 commit 8453a84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ func Execute() {
}

func exitWithError(err error) {
fmt.Println(color.RedString(err.Error()))
fmt.Fprintf(color.Error, "%s\n", color.RedString(err.Error()))
os.Exit(1)
}
5 changes: 2 additions & 3 deletions cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/sundowndev/phoneinfoga/v2/lib/number"
"github.com/sundowndev/phoneinfoga/v2/lib/output"
"github.com/sundowndev/phoneinfoga/v2/lib/remote"
"os"
)

type ScanCmdOptions struct {
Expand Down Expand Up @@ -53,7 +52,7 @@ func NewScanCmd(opts *ScanCmdOptions) *cobra.Command {
}

func runScan(opts *ScanCmdOptions) {
fmt.Printf(color.WhiteString("Running scan for phone number %s...\n\n"), opts.Number)
fmt.Fprintf(color.Output, color.WhiteString("Running scan for phone number %s...\n\n"), opts.Number)

if valid := number.IsValid(opts.Number); !valid {
logrus.WithFields(map[string]interface{}{
Expand Down Expand Up @@ -83,7 +82,7 @@ func runScan(opts *ScanCmdOptions) {

result, errs := remoteLibrary.Scan(num)

err = output.GetOutput(output.Console, os.Stdout).Write(result, errs)
err = output.GetOutput(output.Console, color.Output).Write(result, errs)
if err != nil {
exitWithError(err)
}
Expand Down
3 changes: 3 additions & 0 deletions web/v2/api/server/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package server

import (
"github.com/fatih/color"
"github.com/gin-gonic/gin"
"github.com/sundowndev/phoneinfoga/v2/web/v2/api"
"github.com/sundowndev/phoneinfoga/v2/web/v2/api/handlers"
Expand All @@ -12,6 +13,8 @@ type Server struct {
}

func NewServer() *Server {
gin.DefaultWriter = color.Output
gin.DefaultErrorWriter = color.Error
s := &Server{
router: gin.Default(),
}
Expand Down

0 comments on commit 8453a84

Please sign in to comment.