From 24dcb9702a674646c6a1107c76312fe10307eeca Mon Sep 17 00:00:00 2001 From: gutmet Date: Wed, 26 Jun 2019 23:05:30 +0200 Subject: [PATCH] add flag -nodisplay to 'show' command --- hdiet.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hdiet.go b/hdiet.go index 33f4d7a..d14737f 100644 --- a/hdiet.go +++ b/hdiet.go @@ -131,8 +131,9 @@ func process(file string) ([]point, error) { } type showFlags struct { - from DateFlag - to DateFlag + from DateFlag + to DateFlag + nodisplay bool } func show(args showFlags) error { @@ -172,7 +173,11 @@ func show(args showFlags) error { if err != nil { return err } - return openGraphFile() + if args.nodisplay { + return nil + } else { + return openGraphFile() + } } func showCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) { @@ -180,6 +185,7 @@ func showCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) { flagsInit := func(s *flag.FlagSet) { s.Var(&sf.from, "from", "YYYY-MM-DD (optional)") s.Var(&sf.to, "to", "YYYY-MM-DD (optional)") + s.BoolVar(&sf.nodisplay, "nodisplay", false, "don't display graph image") } return flagsInit, func([]string) error { return show(sf) } }