add support for converting multiple directories simultaneously
This commit is contained in:
parent
2c7ab48825
commit
7ab45c816f
18
config.go
18
config.go
|
@ -34,7 +34,7 @@ type Config struct {
|
|||
|
||||
// Input defines the directory path, containing all asset files as
|
||||
// well as whether to recursively process assets in any sub directories.
|
||||
Input InputConfig
|
||||
Input []InputConfig
|
||||
|
||||
// Output defines the output file for the generated code.
|
||||
// If left empty, this defaults to 'bindata.go' in the current
|
||||
|
@ -140,13 +140,15 @@ func (c *Config) validate() error {
|
|||
return fmt.Errorf("Missing package name")
|
||||
}
|
||||
|
||||
stat, err := os.Lstat(c.Input.Path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Input path: %v", err)
|
||||
}
|
||||
for _, input := range c.Input {
|
||||
stat, err := os.Lstat(input.Path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to stat input path '%s': %v", input.Path, err)
|
||||
}
|
||||
|
||||
if !stat.IsDir() {
|
||||
return fmt.Errorf("Input path is not a directory.")
|
||||
if !stat.IsDir() {
|
||||
return fmt.Errorf("Input path '%s' is not a directory.", input.Path)
|
||||
}
|
||||
}
|
||||
|
||||
if len(c.Output) == 0 {
|
||||
|
@ -158,7 +160,7 @@ func (c *Config) validate() error {
|
|||
c.Output = filepath.Join(cwd, "bindata.go")
|
||||
}
|
||||
|
||||
stat, err = os.Lstat(c.Output)
|
||||
stat, err := os.Lstat(c.Output)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("Output path: %v", err)
|
||||
|
|
|
@ -26,9 +26,11 @@ func Translate(c *Config) error {
|
|||
}
|
||||
|
||||
// Locate all the assets.
|
||||
err = findFiles(c.Input.Path, c.Prefix, c.Input.Recursive, &toc)
|
||||
if err != nil {
|
||||
return err
|
||||
for _, input := range c.Input {
|
||||
err = findFiles(input.Path, c.Prefix, input.Recursive, &toc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Create output file.
|
||||
|
|
|
@ -60,7 +60,7 @@ func parseArgs() *bindata.Config {
|
|||
|
||||
input := filepath.Clean(flag.Arg(0))
|
||||
|
||||
c.Input = parseInput(input)
|
||||
c.Input = []bindata.InputConfig{parseInput(input)}
|
||||
if flag.NArg() > 1 {
|
||||
c.Output = filepath.Clean(flag.Arg(1))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user