From 3f5d69ea9a0c025f9ce8b6a27341a34f0a30b17d Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Sun, 7 Jun 2015 12:29:57 -0700 Subject: [PATCH] parse flags before passing them to subroutine handlers --- lucifer/main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lucifer/main.go b/lucifer/main.go index 336d9fa..6e2be6f 100644 --- a/lucifer/main.go +++ b/lucifer/main.go @@ -144,10 +144,6 @@ func doInvalidate(flags *flag.FlagSet, sync bool, verbose bool) { } func doRun(flags *flag.FlagSet, bail bool, verbose bool) { - err := flags.Parse(os.Args[2:]) - if err != nil { - handleError(err, verbose) - } args := flags.Args() var fnames []Filename for i := 0; i < len(args); i++ { @@ -169,8 +165,16 @@ func main() { runverbose := runflags.Bool("verbose", false, "Verbose response output") switch os.Args[1] { case "invalidate": + err := invalidateflags.Parse(os.Args[2:]) + if err != nil { + handleError(err, true) + } doInvalidate(invalidateflags, *sync, *verbose) case "run": + err := runflags.Parse(os.Args[2:]) + if err != nil { + handleError(err, true) + } doRun(runflags, *bail, *runverbose) default: usage()