filewriting enabled, gofmt

This commit is contained in:
probandula
2016-11-03 10:25:51 +01:00
parent a933237ded
commit a6d9470b73
5 changed files with 38 additions and 18 deletions

View File

@@ -15,6 +15,7 @@ var (
fontpath *string = flag.String("fontpath", "", "Font path to load fonts from")
colors *string = flag.String("colors", "", "Character colors separated by ';'\n\tPossible colors: black, red, green, yellow, blue, magenta, cyan, white, or any hexcode (f.e. '885DBA')")
parser *string = flag.String("parser", "terminal", "Parser to use\tPossible parsers: terminal (default), html")
file *string = flag.String("file", "", "File to write to")
)
func main() {
@@ -54,6 +55,24 @@ func main() {
log.Fatal(err)
}
// Write to file if given
if *file != "" {
// Create file
f, err := os.Create(*file)
defer f.Close()
if err != nil {
log.Fatal(err)
}
// Write to file
b, err := f.WriteString(renderStr)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Wrote %d bytes to %s\n", b, *file)
return
}
// Default is printing
fmt.Print(renderStr)
}