Skip to content

Commit

Permalink
Improve help output; remove -h and -V since wc does not have them
Browse files Browse the repository at this point in the history
  • Loading branch information
timdp committed Apr 28, 2018
1 parent 49e8c11 commit 73f03e9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions internal/app/lwc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,29 @@ type Config struct {
}

func (c *Config) PrintUsage() {
c.g.PrintUsage(lwcutil.GetStdout())
writer := lwcutil.GetStdout()
c.g.PrintUsage(writer)
fmt.Fprintln(writer, "\nFull documentation at: <https://github.com/timdp/lwc>")
}

func NewConfig(args []string) *Config {
intervalMs := DEFAULT_INTERVAL
var c Config
c.g = getopt.New()
c.g.SetParameters("[file ...]")
c.g.FlagLong(&c.Lines, "lines", 'l', "print the newline counts")
c.g.FlagLong(&c.Words, "words", 'w', "print the word counts")
c.g.FlagLong(&c.Chars, "chars", 'm', "print the character counts")
c.g.FlagLong(&c.Bytes, "bytes", 'c', "print the byte counts")
c.g.FlagLong(&c.MaxLineLength, "max-line-length", 'L', "print the maximum display width")
c.g.FlagLong(&c.Files0From, "files0-from", 0, "read input from the files specified by NUL-terminated names in file F")
c.g.FlagLong(&c.Files0From, "files0-from", 0,
"read input from the files specified by NUL-terminated names in file F",
"F")
c.g.FlagLong(&intervalMs, "interval", 'i',
fmt.Sprintf("set update interval in ms (default %d ms)", DEFAULT_INTERVAL))
c.g.FlagLong(&c.Help, "help", 'h', "display this help and exit")
c.g.FlagLong(&c.Version, "version", 'V', "output version information and exit")
fmt.Sprintf("set the update interval to T ms (default %d ms)", DEFAULT_INTERVAL),
"T")
c.g.FlagLong(&c.Help, "help", 0, "display this help and exit")
c.g.FlagLong(&c.Version, "version", 0, "output version information and exit")
c.g.Parse(args)
if intervalMs < 0 {
lwcutil.Fatal("Update interval cannot be negative")
Expand Down

0 comments on commit 73f03e9

Please sign in to comment.