version bump: v0.3.2

This commit is contained in:
Mark Bates 2019-10-22 13:29:08 -04:00
parent 3c88088905
commit 9a2162e1a0
3 changed files with 2 additions and 65 deletions

View File

@ -90,7 +90,7 @@ func New() (*packCmd, error) {
c := &packCmd{}
c.subs = []command{
&readCmd{}, &serveCmd{}, &statCmd{}, &infoCmd{},
&serveCmd{}, &statCmd{}, &infoCmd{},
}
sort.Slice(c.subs, func(a, b int) bool {
return c.subs[a].Name() <= c.subs[b].Name()

View File

@ -1,63 +0,0 @@
package cmds
import (
"encoding/json"
"flag"
"fmt"
"io"
"os"
"github.com/markbates/pkger"
)
type readCmd struct {
*flag.FlagSet
JSON bool
}
func (s *readCmd) Name() string {
return s.Flags().Name()
}
func (r *readCmd) Flags() *flag.FlagSet {
if r.FlagSet == nil {
r.FlagSet = flag.NewFlagSet("read", flag.ExitOnError)
r.FlagSet.BoolVar(&r.JSON, "json", false, "print as JSON")
}
return r.FlagSet
}
func (r *readCmd) Exec(args []string) error {
if len(args) == 0 {
args = []string{"."}
}
for _, a := range args {
f, err := pkger.Open(a)
if err != nil {
return err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return err
}
if fi.IsDir() && !r.JSON {
return fmt.Errorf("can not read a dir %s", a)
}
if r.JSON {
err = json.NewEncoder(os.Stdout).Encode(f)
if err != nil {
return err
}
continue
}
_, err = io.Copy(os.Stdout, f)
if err != nil {
return err
}
}
return nil
}

View File

@ -1,4 +1,4 @@
package pkger
// Version of pkger
const Version = "v0.3.1"
const Version = "v0.3.2"