Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #25 from markbates/out-flag
Browse files Browse the repository at this point in the history
add -o flag
  • Loading branch information
markbates committed Nov 10, 2019
2 parents 342e00a + 5c0596f commit 834898d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/pkger/cmds/pack.go
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/markbates/pkger"
"github.com/markbates/pkger/here"
"github.com/markbates/pkger/parser"
"github.com/markbates/pkger/pkging/pkgutil"
)
Expand All @@ -17,6 +18,7 @@ const outName = "pkged.go"

type packCmd struct {
*flag.FlagSet
out string
help bool
subs []command
}
Expand All @@ -31,7 +33,7 @@ func (e *packCmd) Exec(args []string) error {
return err
}

fp := filepath.Join(info.Dir, outName)
fp := filepath.Join(info.Dir, e.out, outName)
os.RemoveAll(fp)

decls, err := parser.Parse(info)
Expand Down Expand Up @@ -89,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)()
Expand Down Expand Up @@ -116,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
}
Expand Down

0 comments on commit 834898d

Please sign in to comment.