diff --git a/cmd/pkger/cmds/pack.go b/cmd/pkger/cmds/pack.go index 009500f..5feec33 100644 --- a/cmd/pkger/cmds/pack.go +++ b/cmd/pkger/cmds/pack.go @@ -4,10 +4,12 @@ import ( "flag" "fmt" "os" + "path/filepath" "sort" "strings" "github.com/markbates/pkger" + "github.com/markbates/pkger/here" "github.com/markbates/pkger/parser" "github.com/markbates/pkger/pkging/pkgutil" ) @@ -16,6 +18,7 @@ const outName = "pkged.go" type packCmd struct { *flag.FlagSet + out string help bool subs []command } @@ -30,7 +33,7 @@ func (e *packCmd) Exec(args []string) error { return err } - fp := info.FilePath(outName) + fp := filepath.Join(info.Dir, e.out, outName) os.RemoveAll(fp) decls, err := parser.Parse(info) @@ -88,6 +91,7 @@ func New() (*packCmd, error) { c.FlagSet = flag.NewFlagSet("pkger", flag.ExitOnError) c.BoolVar(&c.help, "h", false, "prints help information") + c.StringVar(&c.out, "o", "", "output directory for pkged.go") c.Usage = func() { fmt.Fprintf(os.Stderr, "Usage:\n\n") Usage(os.Stderr, c.FlagSet)() @@ -115,7 +119,7 @@ func Package(out string, decls parser.Decls) error { } defer f.Close() - c, err := pkger.Current() + c, err := here.Dir(filepath.Dir(out)) if err != nil { return err }