Ejemplo n.º 1
0
func (c *emojiConfig) Render(r iface.Data, unitSystem iface.UnitSystem) {
	c.unit = unitSystem

	fmt.Printf("Weather for %s\n\n", r.Location)
	stdout := colorable.NewColorableStdout()

	out := c.formatCond(make([]string, 5), r.Current, true)
	for _, val := range out {
		fmt.Fprintln(stdout, val)
	}

	if len(r.Forecast) == 0 {
		return
	}
	if r.Forecast == nil {
		log.Fatal("No detailed weather forecast available.")
	}
	for _, d := range r.Forecast {
		for _, val := range c.printDay(d) {
			fmt.Fprintln(stdout, val)
		}
	}
}
Ejemplo n.º 2
0
func initFunc() {
	log.SetLevel(log.WarnLevel)
	log.SetOutput(colorable.NewColorableStdout())
}
Ejemplo n.º 3
0
Archivo: ui.go Proyecto: bogem/vnehm
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package ui

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"time"

	colorable "github.com/mattn/go-colorable"
)

var Output = colorable.NewColorableStdout()

func Error(message string, err error) {
	out := "ERROR: "
	if err == nil {
		out += message
	} else if message == "" {
		out += err.Error()
	} else {
		out += message + ": " + err.Error()
	}
	Println(RedString(out))
}

func Newline() {
	Println("")
Ejemplo n.º 4
0
func init() {
	log.SetLevel(log.InfoLevel)
	log.SetOutput(colorable.NewColorableStdout())
}
Ejemplo n.º 5
0
// Provides colorable stdout and stderr streams
package colorable

import (
	c "github.com/mattn/go-colorable"
)

// Colorable-aware stdout, similar to os.Stdout
var Stdout = c.NewColorableStdout()

// Colorable-aware stderr, similar to os.Stderr
var Stderr = c.NewColorableStderr()