From 3cecfd9370598e9fcfb7b4d5bc301d8a1eed41d9 Mon Sep 17 00:00:00 2001 From: Tim De Pauw Date: Wed, 25 Apr 2018 15:26:56 +0200 Subject: [PATCH] Simplify config --- internal/app/lwc/config.go | 24 ++++++++++++------------ internal/app/lwc/process.go | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/app/lwc/config.go b/internal/app/lwc/config.go index eed5c8c..8894513 100644 --- a/internal/app/lwc/config.go +++ b/internal/app/lwc/config.go @@ -11,10 +11,10 @@ import ( const DEFAULT_INTERVAL int = 100 type Config struct { - CountLines bool - CountWords bool - CountChars bool - CountBytes bool + Lines bool + Words bool + Chars bool + Bytes bool MaxLineLength bool Interval time.Duration Help bool @@ -25,10 +25,10 @@ type Config struct { func BuildConfig() Config { var config Config intervalMs := DEFAULT_INTERVAL - getopt.FlagLong(&config.CountLines, "lines", 'l', "print the newline counts") - getopt.FlagLong(&config.CountWords, "words", 'w', "print the word counts") - getopt.FlagLong(&config.CountChars, "chars", 'm', "print the character counts") - getopt.FlagLong(&config.CountBytes, "bytes", 'c', "print the byte counts") + getopt.FlagLong(&config.Lines, "lines", 'l', "print the newline counts") + getopt.FlagLong(&config.Words, "words", 'w', "print the word counts") + getopt.FlagLong(&config.Chars, "chars", 'm', "print the character counts") + getopt.FlagLong(&config.Bytes, "bytes", 'c', "print the byte counts") getopt.FlagLong(&config.MaxLineLength, "max-line-length", 'L', "print the maximum display width") getopt.FlagLong(&intervalMs, "interval", 'i', fmt.Sprintf("set update interval in ms (default %d ms)", DEFAULT_INTERVAL)) @@ -37,10 +37,10 @@ func BuildConfig() Config { getopt.Parse() config.Interval = time.Duration(intervalMs * 1e6) config.Files = getopt.Args() - if !(config.CountLines || config.CountWords || config.CountChars || config.CountBytes) { - config.CountLines = true - config.CountWords = true - config.CountBytes = true + if !(config.Lines || config.Words || config.Chars || config.Bytes) { + config.Lines = true + config.Words = true + config.Bytes = true } return config } diff --git a/internal/app/lwc/process.go b/internal/app/lwc/process.go index 5878a58..12e34f8 100644 --- a/internal/app/lwc/process.go +++ b/internal/app/lwc/process.go @@ -19,19 +19,19 @@ type Processor struct { func BuildProcessors(config *Config) []Processor { var temp [5]Processor i := 0 - if config.CountLines { + if config.Lines { temp[i] = Processor{bufio.ScanLines, ScanCount} i++ } - if config.CountWords { + if config.Words { temp[i] = Processor{bufio.ScanWords, ScanCount} i++ } - if config.CountChars { + if config.Chars { temp[i] = Processor{bufio.ScanRunes, ScanCount} i++ } - if config.CountBytes { + if config.Bytes { temp[i] = Processor{bufio.ScanBytes, ScanCount} i++ }