Skip to content

Commit 4671a58

Browse files
baruchlubinskyshuLhan
authored andcommitted
change default package to containing folder of output
1 parent a0ff256 commit 4671a58

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

go-bindata/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ func parseArgs() *bindata.Config {
8282
c.Input[i] = parseInput(flag.Arg(i))
8383
}
8484

85+
// Change pkg to containing directory of output. If output flag is set and package flag is not.
86+
pkgSet := false
87+
outputSet := false
88+
flag.Visit(func(f *flag.Flag) {
89+
if f.Name == "pkg" {
90+
pkgSet = true
91+
}
92+
if f.Name == "o" {
93+
outputSet = true
94+
}
95+
})
96+
if outputSet && !pkgSet {
97+
pkg := filepath.Base(filepath.Dir(c.Output))
98+
if pkg != "." && pkg != "/" {
99+
c.Package = pkg
100+
}
101+
}
102+
85103
return c
86104
}
87105

0 commit comments

Comments
 (0)