Files
distrobox/pkg/ui/printer.go
T
Emanuele De Cupis 5a9649e6ee chore(repo): make the go rewrite the root project (#60)
* chore(repo): remove shell implementation

* chore(repo): remove bash completion for sub-commands

There is no need for separate files as there will be no dedicated binary
for sub-commands

* chore(repo): remove zsh completion for sub-commands

There is no need for separate files as there will be no dedicated binary
for sub-commands

* chore(repo): delete RFC

We are not using RFC at the moment

* chore(repo): move golang project to the root

* chore(ci): move golang project to the root

* chore(repo): use standard .gitignore for golang projects

source: https://github.com/github/gitignore/blob/main/Go.gitignore

* chore(ci): compatibility CI to handle a golang project

* refactor(ci): run shell script checks against the inside-distrobox files

* refactor(ci): merge ci.yml workflow into main.yml
2026-06-14 13:04:28 +02:00

55 lines
855 B
Go

package ui
import (
"fmt"
"io"
)
type Printer struct {
writer io.Writer
colorful bool
}
func NewPrinter(writer io.Writer, colorful bool) *Printer {
return &Printer{
writer: writer,
colorful: colorful,
}
}
func (p *Printer) Print(msg string, a ...any) {
fmt.Fprintf(p.writer, msg, a...)
}
func (p *Printer) Println(msg string, a ...any) {
p.Print(msg+"\n", a...)
}
func (p *Printer) PrintWarning(msg string, a ...any) {
if p.colorful {
msg = Yellow(msg)
}
p.Print(msg, a...)
}
func (p *Printer) PrintWarningln(msg string, a ...any) {
if p.colorful {
msg = Yellow(msg)
}
p.Println(msg, a...)
}
func (p *Printer) PrintError(msg string, a ...any) {
if p.colorful {
msg = Red(msg)
}
p.Print(msg, a...)
}
func (p *Printer) PrintErrorln(msg string, a ...any) {
if p.colorful {
msg = Red(msg)
}
p.Println(msg, a...)
}