Skip to content

Commit

Permalink
parse flags before passing them to subroutine handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinburke committed Jun 7, 2015
1 parent f7db389 commit 3f5d69e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lucifer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand All @@ -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()
Expand Down

0 comments on commit 3f5d69e

Please sign in to comment.