From c508d152d230d5e3e7099e78679b60c431cb92ec Mon Sep 17 00:00:00 2001 From: nate smith Date: Wed, 31 Jan 2024 21:46:43 -0800 Subject: [PATCH] wip --- cmd/gutcontent/main.go | 15 ++------------- cmd/phraser/main.go | 6 ++++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/cmd/gutcontent/main.go b/cmd/gutcontent/main.go index 7484ec1..7bd4bb8 100644 --- a/cmd/gutcontent/main.go +++ b/cmd/gutcontent/main.go @@ -1,5 +1,5 @@ /* -Given a project gutenberg plaintext book filename, this program prints just its content (ie with header and footer stripped) +Given a project gutenberg plaintext book on STDIN, this program prints just its content (ie with header and footer stripped) */ package main @@ -12,18 +12,7 @@ import ( ) func main() { - if len(os.Args) < 2 { - fmt.Fprintln(os.Stderr, "need a filename argument") - os.Exit(1) - } - filename := os.Args[1] - f, err := os.Open(filename) - if err != nil { - fmt.Fprintf(os.Stderr, "could not open '%s' for reading\n", filename) - os.Exit(2) - } - - s := bufio.NewScanner(f) + s := bufio.NewScanner(os.Stdin) inHeader := true inFooter := false skippedAll := true diff --git a/cmd/phraser/main.go b/cmd/phraser/main.go index c4c49b9..2597de2 100644 --- a/cmd/phraser/main.go +++ b/cmd/phraser/main.go @@ -63,3 +63,9 @@ func main() { } } } + +func clean(s string) string { + s = strings.ReplaceAll(s, "’", "'") + + return s +}