Skip to content

Commit

Permalink
dag: Update color code
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGamba committed Oct 9, 2024
1 parent ffca682 commit 4dc86a8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 69 deletions.
34 changes: 34 additions & 0 deletions dag/color.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dag

import (
"fmt"
"strings"
)

func (g *Graph) colorInfo(format string) string {
return g.color(g.InfoColor, format)
}

func (g *Graph) colorInfoBold(format string) string {
return g.color(g.InfoBoldColor, format)
}

func (g *Graph) colorError(format string) string {
return g.color(g.ErrorColor, format)
}

func (g *Graph) colorErrorBold(format string) string {
return g.color(g.ErrorBoldColor, format)
}

func (g *Graph) color(color string, format string) string {
if !g.UseColor {
return format
}
if !strings.HasSuffix(format, "\n") {
return fmt.Sprintf("\033[%sm%s\033[0m", color, format)
}

format = format[:len(format)-1]
return fmt.Sprintf("\033[%sm%s\033[0m\n", color, format)
}
3 changes: 3 additions & 0 deletions dag/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"sync"
"time"

"github.com/DavidGamba/go-getoptions"
)

var Logger = log.New(os.Stderr, "", log.LstdFlags)

type (
ID string

Expand Down
69 changes: 0 additions & 69 deletions dag/logger.go

This file was deleted.

0 comments on commit 4dc86a8

Please sign in to comment.