Exemplo n.º 1
0
func TestPrintInFormat(t *testing.T) {
	ch = make(chan string, 1)
	cli.Out = WriterFunc(Write)
	cli.Print("{red}Some text in red. {white}Some text in white. {default}Some text in default color.").InFormat()
	str := <-ch

	expected := "\033[31mSome text in red. \033[0m\033[37mSome text in white. \033[0m\033[39mSome text in default color.\033[0m\n"
	if str != expected {
		t.Error("Expected", expected, "Got", str)
	}

	close(ch)
}
Exemplo n.º 2
0
func TestPrintIn(t *testing.T) {
	ch = make(chan string, 1)
	cli.Out = WriterFunc(Write)
	cli.Print("this is green text").In("green")
	str := <-ch

	expected := "\033[32mthis is green text\033[0m\n"
	if str != expected {
		t.Error("Expected", expected)
	}

	close(ch)
}
Exemplo n.º 3
0
func PrintMeSomething() {
	cli.Print("some text").In("green")
	cli.Print("{red}Some text in red. {white}Some text in white. {default}Some text in default color").InFormat()
}
Exemplo n.º 4
0
func PrintForThePeople() {
	cli.Print("some text").In("blue")
}
Exemplo n.º 5
0
func ExamplePrint_inFormat() {
	cli.Print("{red}Some text in red. {white}Some text in white. {default}Some text in default color.").InFormat()
	// prints: Some text in red. Some text in white. Some text in default color.
}
Exemplo n.º 6
0
func ExamplePrint_in() {
	cli.Print("this is green text").In("green")
	// prints: this is green text
}