Merge branch 'linebreaks_on_console_messages' of asdf/gfu into master

This commit is contained in:
Sloom Sloum Sluom IV 2019-09-15 22:30:33 -04:00 committed by Gitea
commit 3a2aaaec36
1 changed files with 13 additions and 13 deletions

26
main.go
View File

@ -1,13 +1,13 @@
package main
import (
"strings"
"bytes"
"os"
"fmt"
"bufio"
"regexp"
"bytes"
"flag"
"fmt"
"os"
"regexp"
"strings"
)
var outFile bytes.Buffer
@ -45,7 +45,7 @@ func deconstructComment(ln string) string {
func readFile(path string, buildComments bool) {
file, err := os.Open(path)
errorExit(err, fmt.Sprintf("Unable to open file for reading: %s", path))
errorExit(err, fmt.Sprintf("Unable to open file for reading: %s\n", path))
defer file.Close()
re := regexp.MustCompile(`.+\t.*\t.*\t.*`)
@ -80,8 +80,8 @@ func readFile(path string, buildComments bool) {
}
func writeFile(path string) {
file, err := os.OpenFile(path, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0)
errorExit(err, fmt.Sprintf("Unable to open file for writing: %s", path))
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0)
errorExit(err, fmt.Sprintf("Unable to open file for writing: %s\n", path))
defer file.Close()
file.Write(outFile.Bytes())
}
@ -103,16 +103,16 @@ example: gfu -d ~/gopher/phlog/gophermap
func main() {
deconstructCommentLinks := flag.Bool("d", false, "Deconstruct a gophermap's comments back to regular text")
header := flag.String("head","","Path to a file containing header content")
footer := flag.String("foot","","Path to a file containing footer content")
header := flag.String("head", "", "Path to a file containing header content")
footer := flag.String("foot", "", "Path to a file containing footer content")
flag.Usage = PrintHelp
flag.Parse()
args := flag.Args()
if l := len(args); l != 1 {
fmt.Printf("Incorrect number of arguments. Expected 1, got %d", l)
fmt.Printf("Incorrect number of arguments. Expected 1, got %d\n", l)
os.Exit(1)
}