Compare commits
No commits in common. "main" and "main" have entirely different histories.
@ -122,32 +122,27 @@ func appMain(c *cli.Context) (err error) {
|
||||
printSupportedExtensions()
|
||||
return nil
|
||||
}
|
||||
|
||||
var inputs []string
|
||||
input := c.String("input")
|
||||
if input != "" {
|
||||
inputs = append(inputs, input)
|
||||
if input == "" {
|
||||
switch c.Args().Len() {
|
||||
case 0:
|
||||
input = cwd
|
||||
case 1:
|
||||
input = c.Args().Get(0)
|
||||
default:
|
||||
return errors.New("please specify input file (or directory)")
|
||||
}
|
||||
}
|
||||
|
||||
if c.Args().Len() > 0 {
|
||||
inputs = append(inputs, c.Args().Slice()...)
|
||||
}
|
||||
|
||||
if len(inputs) == 0 {
|
||||
inputs = append(inputs, cwd)
|
||||
}
|
||||
|
||||
for _, input := range inputs {
|
||||
input, absErr := filepath.Abs(input)
|
||||
if absErr != nil {
|
||||
logger.Warn("get abs path failed", zap.String("input", input), zap.Error(absErr))
|
||||
continue
|
||||
return fmt.Errorf("get abs path failed: %w", absErr)
|
||||
}
|
||||
|
||||
output := c.String("output")
|
||||
inputStat, err := os.Stat(input)
|
||||
if err != nil {
|
||||
logger.Warn("stat input failed", zap.String("input", input), zap.Error(err))
|
||||
continue
|
||||
return err
|
||||
}
|
||||
|
||||
var inputDir string
|
||||
@ -161,7 +156,6 @@ func appMain(c *cli.Context) (err error) {
|
||||
return fmt.Errorf("get abs path (inputDir) failed: %w", absErr)
|
||||
}
|
||||
|
||||
output := c.String("output")
|
||||
if output == "" {
|
||||
// Default to where the input dir is
|
||||
output = inputDir
|
||||
@ -202,19 +196,14 @@ func appMain(c *cli.Context) (err error) {
|
||||
if inputStat.IsDir() {
|
||||
watchDir := c.Bool("watch")
|
||||
if !watchDir {
|
||||
err = proc.processDir(input)
|
||||
return proc.processDir(input)
|
||||
} else {
|
||||
err = proc.watchDir(input)
|
||||
return proc.watchDir(input)
|
||||
}
|
||||
} else {
|
||||
err = proc.processFile(input)
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("conversion failed", zap.String("source", input), zap.Error(err))
|
||||
}
|
||||
return proc.processFile(input)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type processor struct {
|
||||
|
Loading…
Reference in New Issue
Block a user