Skip to content

Commit

Permalink
change default package to containing folder of output
Browse files Browse the repository at this point in the history
  • Loading branch information
baruchlubinsky authored and shuLhan committed Sep 8, 2017
1 parent a0ff256 commit 4671a58
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions go-bindata/main.go
Expand Up @@ -82,6 +82,24 @@ func parseArgs() *bindata.Config {
c.Input[i] = parseInput(flag.Arg(i))
}

// Change pkg to containing directory of output. If output flag is set and package flag is not.
pkgSet := false
outputSet := false
flag.Visit(func(f *flag.Flag) {
if f.Name == "pkg" {
pkgSet = true
}
if f.Name == "o" {
outputSet = true
}
})
if outputSet && !pkgSet {
pkg := filepath.Base(filepath.Dir(c.Output))
if pkg != "." && pkg != "/" {
c.Package = pkg
}
}

return c
}

Expand Down

0 comments on commit 4671a58

Please sign in to comment.