Example #1
0
func DisplayPullRequests(c *cli.Context, pulls []*gh.PullRequest, notrunc bool) {
	w := newTabwriter()
	fmt.Fprintf(w, "NUMBER\tLAST UPDATED\tTITLE")
	if c.Bool("lgtm") {
		fmt.Fprintf(w, "\tLGTM")
	}
	fmt.Fprintf(w, "\n")
	for _, p := range pulls {
		if !notrunc {
			p.Title = truncate(p.Title)
		}
		fmt.Fprintf(w, "%d\t%s\t%s", p.Number, HumanDuration(time.Since(p.UpdatedAt)), p.Title)
		if c.Bool("lgtm") {
			lgtm := strconv.Itoa(p.ReviewComments)
			if p.ReviewComments >= 2 {
				lgtm = brush.Green(lgtm).String()
			} else if p.ReviewComments == 0 {
				lgtm = brush.DarkRed(lgtm).String()
			} else {
				lgtm = brush.DarkYellow(lgtm).String()
			}
			fmt.Fprintf(w, "\t%s", lgtm)
		}
		fmt.Fprintf(w, "\n")
	}

	if err := w.Flush(); err != nil {
		fmt.Fprintf(os.Stderr, "%s", err)
	}
}
Example #2
0
var stderr_std_logger *log.Logger

var prefixes = map[int]string{
	DEBUG:   "[debug] ",
	INFO:    "[info] ",
	WARNING: "[warning] ",
	ERROR:   "[error] ",
	FATAL:   "[fatal] ",
}

var coloredPrefixes = map[int]string{
	DEBUG:   brush.Cyan("[debug] ").String(),
	INFO:    brush.Green("[info] ").String(),
	WARNING: brush.Yellow("[warning] ").String(),
	ERROR:   brush.Red("[error] ").String(),
	FATAL:   brush.DarkRed("[fatal] ").String(),
}

type Stdout struct {
	MinLevel int
	Colored  bool
}

func init() {
	stdout_std_logger = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
	stderr_std_logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)
}

func (s Stdout) std_format_message(level int, message string) (int, string) {
	if s.Colored {
		return 4, coloredPrefixes[level] + message
Example #3
0
File: color.go Project: askb/gordon
func DarkRed(s string) string {
	if Colorize {
		return brush.DarkRed(s).String()
	}
	return s
}