func BoldRed(msg interface{}) string {
	return color.New(color.FgRed).Add(color.Bold).Sprint(msg)
}
BoldRed returns a string formatted with red and bold.
package printer
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
	"time"
	"github.com/briandowns/spinner"
	"github.com/fatih/color"
	"github.com/gocarina/gocsv"
	"github.com/lensesio/tableprinter"
	"github.com/mattn/go-isatty"
)
var IsTTY = isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd())
type Format int
const (
	Human Format = iota
	JSON
	CSV
)
func NewFormatValue(val Format, p *Format) *Format {
	*p = val
	return (*Format)(p)
}
func (f *Format) String() string {
	switch *f {
	case Human:
		return "human"
	case JSON:
		return "json"
	case CSV:
		return "csv"
	}
	return "unknown format"
}
func (f *Format) Set(s string) error {
	var v Format
	switch s {
	case "human":
		v = Human
	case "json":
		v = JSON
	case "csv":
		v = CSV
	default:
		return fmt.Errorf("failed to parse Format: %q. Valid values: %+v",
			s, []string{"human", "json", "csv"})
	}
	*f = Format(v)
	return nil
}
func (f *Format) Type() string {
	return "string"
}
type Printer struct {
	humanOut    io.Writer
	resourceOut io.Writer
	format *Format
}
func NewPrinter(format *Format) *Printer {
	return &Printer{
		format: format,
	}
}
func (p *Printer) Printf(format string, i ...interface{}) {
	fmt.Fprintf(p.out(), format, i...)
}
func (p *Printer) Println(i ...interface{}) {
	fmt.Fprintln(p.out(), i...)
}
func (p *Printer) Print(i ...interface{}) {
	fmt.Fprint(p.out(), i...)
}
func (p *Printer) out() io.Writer {
	if p.humanOut != nil {
		return p.humanOut
	}
	if *p.format == Human {
		return color.Output
	}
	return ioutil.Discard  
}
func (p *Printer) PrintProgress(message string) func() {
	if !IsTTY {
		fmt.Fprintln(p.out(), message)
		return func() {}
	}
	s := spinner.New(spinner.CharSets[14], 100*time.Millisecond, spinner.WithWriter(p.out()))
	s.Suffix = fmt.Sprintf(" %s", message)
	s.Color("bold", "green")  
	s.Start()
	return func() {
		s.Stop()
		fmt.Fprint(p.out(), "\r\033[2K")
	}
}
func (p *Printer) Format() Format { return *p.format }
func (p *Printer) SetHumanOutput(out io.Writer) {
	p.humanOut = out
}
func (p *Printer) SetResourceOutput(out io.Writer) {
	p.resourceOut = out
}
func (p *Printer) PrintResource(v interface{}) error {
	if p.format == nil {
		return errors.New("printer.Format is not set")
	}
	var out io.Writer = os.Stdout
	if p.resourceOut != nil {
		out = p.resourceOut
	}
	switch *p.format {
	case Human:
		var b strings.Builder
		tableprinter.Print(&b, v)
		fmt.Fprintln(out, b.String())
		return nil
	case JSON:
		buf, err := json.MarshalIndent(v, "", "  ")
		if err != nil {
			return err
		}
		fmt.Fprintln(out, string(buf))
		return nil
	case CSV:
		type csvvaluer interface {
			MarshalCSVValue() interface{}
		}
		if c, ok := v.(csvvaluer); ok {
			v = c.MarshalCSVValue()
		}
		buf, err := gocsv.MarshalString(v)
		if err != nil {
			return err
		}
		fmt.Fprintln(out, buf)
		return nil
	}
	return fmt.Errorf("unknown printer.Format: %T", *p.format)
}
func GetMilliseconds(timestamp time.Time) int64 {
	if timestamp.IsZero() {
		return 0
	}
	numSeconds := timestamp.UTC().UnixNano() /
		(int64(time.Millisecond) / int64(time.Nanosecond))
	return numSeconds
}
func GetMillisecondsIfExists(timestamp *time.Time) *int64 {
	if timestamp == nil {
		return nil
	}
	numSeconds := GetMilliseconds(*timestamp)
	return &numSeconds
}
func Emoji(emoji string) string {
	if IsTTY {
		return emoji
	}
	return ""
}
func BoldBlue(msg interface{}) string {
	return color.New(color.FgBlue).Add(color.Bold).Sprint(msg)
}