From 4d205ba0b81dcf5edb669c2f09e8ab1ce4833ceb Mon Sep 17 00:00:00 2001 From: knolax <1339802534.kk@gmail.com> Date: Thu, 19 Jan 2017 13:21:46 +0000 Subject: added debug mode --- letters.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/letters.go b/letters.go index 868fac1..cc0a154 100644 --- a/letters.go +++ b/letters.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "errors" "strconv" + "flag" ) type runedata struct { Field [5][5]bool; @@ -126,8 +127,13 @@ func main () () { var frune rune = '9'; var brune rune = '9'; var cover int = 0; + var debugp *bool; + debugp = flag.Bool("debug",false,"whether or not debug commands are printed"); + flag.Parse(); inpreader := bufio.NewReader(os.Stdin); - fmt.Println("%[0-9] for foreground color, $[0-9] for background color, [ to replace using $9%9 returns the terminal to defaults"); + if *debugp { + fmt.Println("%[0-9] for foreground color, $[0-9] for background color, [ to replace using $9%9 returns the terminal to defaults"); + } var trune rune ; trune , _ ,_ = inpreader.ReadRune() for trune != '\n' { @@ -144,7 +150,9 @@ func main () () { if (inp[i] <= '9') && (inp[i] >= '0') { frune = inp[i]; err = coloradd(frune,brune); - fmt.Println("setting foreground color %c",inp[i]); + if *debugp { + fmt.Println("setting foreground color %c",inp[i]); + } } break; case '$': @@ -152,7 +160,9 @@ func main () () { if (inp[i] <= '9') && (inp[i] >= '0') { brune = inp[i]; err = coloradd(frune,brune); - fmt.Println("setting background color %c",inp[i]); + if *debugp { + fmt.Println("setting background color %c",inp[i]); + } } break; default : @@ -189,6 +199,8 @@ func main () () { fmt.Printf("\n"); i++; } - err = ioutil.WriteFile(string(inp),[]byte(tmpstring),0777); - errc(err); + if *debugp { + err = ioutil.WriteFile(string(inp),[]byte(tmpstring),0777); + errc(err); + } } -- cgit v1.1