Accept individual files as parameters
This commit is contained in:
parent
b040f60a8c
commit
6347e7a31c
|
@ -151,14 +151,10 @@ func (c *Config) validate() error {
|
|||
}
|
||||
|
||||
for _, input := range c.Input {
|
||||
stat, err := os.Lstat(input.Path)
|
||||
_, 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 '%s' is not a directory.", input.Path)
|
||||
}
|
||||
}
|
||||
|
||||
if len(c.Output) == 0 {
|
||||
|
|
14
convert.go
14
convert.go
|
@ -89,6 +89,17 @@ func findFiles(dir, prefix string, recursive bool, toc *[]Asset, ignore []*regex
|
|||
prefix = filepath.ToSlash(prefix)
|
||||
}
|
||||
|
||||
fi, err := os.Stat(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var list []os.FileInfo
|
||||
|
||||
if !fi.IsDir() {
|
||||
dir = ""
|
||||
list = []os.FileInfo{fi}
|
||||
} else {
|
||||
fd, err := os.Open(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -96,10 +107,11 @@ func findFiles(dir, prefix string, recursive bool, toc *[]Asset, ignore []*regex
|
|||
|
||||
defer fd.Close()
|
||||
|
||||
list, err := fd.Readdir(0)
|
||||
list, err = fd.Readdir(0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, file := range list {
|
||||
var asset Asset
|
||||
|
|
Loading…
Reference in New Issue
Block a user