mirror of
https://github.com/KevinMidboe/motdGO.git
synced 2025-10-29 17:50:24 +00:00
filewriting enabled, gofmt
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user