Merge pull request #74 from tschottdorf/master
add `mode` and `modTime` flags
This commit is contained in:
commit
7362d4b6b2
|
@ -127,6 +127,11 @@ type Config struct {
|
||||||
// repository.
|
// repository.
|
||||||
Dev bool
|
Dev bool
|
||||||
|
|
||||||
|
// When nonzero, use this as mode for all files.
|
||||||
|
Mode uint
|
||||||
|
// When nonzero, use this as unix timestamp for all files.
|
||||||
|
ModTime int64
|
||||||
|
|
||||||
// Ignores any filenames matching the regex pattern specified, e.g.
|
// Ignores any filenames matching the regex pattern specified, e.g.
|
||||||
// path/to/file.ext will ignore only that file, or \\.gitignore
|
// path/to/file.ext will ignore only that file, or \\.gitignore
|
||||||
// will match any .gitignore file.
|
// will match any .gitignore file.
|
||||||
|
|
|
@ -47,6 +47,8 @@ func parseArgs() *bindata.Config {
|
||||||
flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.")
|
flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.")
|
||||||
flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.")
|
flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.")
|
||||||
flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.")
|
flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.")
|
||||||
|
flag.UintVar(&c.Mode, "mode", c.Mode, "Optional file mode override for all files.")
|
||||||
|
flag.Int64Var(&c.ModTime, "modtime", c.ModTime, "Optional modification unix timestamp override for all files.")
|
||||||
flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.")
|
flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.")
|
||||||
flag.BoolVar(&version, "version", false, "Displays version information.")
|
flag.BoolVar(&version, "version", false, "Displays version information.")
|
||||||
|
|
||||||
|
|
15
release.go
15
release.go
|
@ -81,7 +81,7 @@ func writeReleaseAsset(w io.Writer, c *Config, asset *Asset) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return asset_release_common(w, asset)
|
return asset_release_common(w, c, asset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitize prepares a valid UTF-8 string as a raw string constant.
|
// sanitize prepares a valid UTF-8 string as a raw string constant.
|
||||||
|
@ -359,12 +359,21 @@ func %s_bytes() ([]byte, error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func asset_release_common(w io.Writer, asset *Asset) error {
|
func asset_release_common(w io.Writer, c *Config, asset *Asset) error {
|
||||||
fi, err := os.Stat(asset.Path)
|
fi, err := os.Stat(asset.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mode := uint(fi.Mode())
|
||||||
|
modTime := fi.ModTime().Unix()
|
||||||
|
|
||||||
|
if c.Mode > 0 {
|
||||||
|
mode = uint(os.ModePerm) & c.Mode
|
||||||
|
}
|
||||||
|
if c.ModTime > 0 {
|
||||||
|
modTime = c.ModTime
|
||||||
|
}
|
||||||
_, err = fmt.Fprintf(w, `func %s() (*asset, error) {
|
_, err = fmt.Fprintf(w, `func %s() (*asset, error) {
|
||||||
bytes, err := %s_bytes()
|
bytes, err := %s_bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -376,6 +385,6 @@ func asset_release_common(w io.Writer, asset *Asset) error {
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
`, asset.Func, asset.Func, asset.Name, fi.Size(), uint32(fi.Mode()), fi.ModTime().Unix())
|
`, asset.Func, asset.Func, asset.Name, fi.Size(), mode, modTime)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user