Compare commits

..

No commits in common. "91855f8f5ba4147adcceffb2d008a05b17d64f9a" and "0b3ad0d97c3004f16bd1ea93b5235a365722842f" have entirely different histories.

View File

@ -8,7 +8,6 @@ import (
"io" "io"
"os" "os"
"os/signal" "os/signal"
"path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
@ -85,11 +84,6 @@ func printSupportedExtensions() {
} }
func appMain(c *cli.Context) (err error) { func appMain(c *cli.Context) (err error) {
cwd, err := os.Getwd()
if err != nil {
return err
}
if c.Bool("supported-ext") { if c.Bool("supported-ext") {
printSupportedExtensions() printSupportedExtensions()
return nil return nil
@ -98,7 +92,10 @@ func appMain(c *cli.Context) (err error) {
if input == "" { if input == "" {
switch c.Args().Len() { switch c.Args().Len() {
case 0: case 0:
input = cwd input, err = os.Getwd()
if err != nil {
return err
}
case 1: case 1:
input = c.Args().Get(0) input = c.Args().Get(0)
default: default:
@ -107,20 +104,22 @@ func appMain(c *cli.Context) (err error) {
} }
output := c.String("output") output := c.String("output")
inputStat, err := os.Stat(input) if output == "" {
var err error
output, err = os.Getwd()
if err != nil { if err != nil {
return err return err
} }
if input == output {
if output == "" { return errors.New("input and output path are same")
// Default to where the input is
if inputStat.IsDir() {
output = input
} else {
output = path.Dir(input)
} }
} }
inputStat, err := os.Stat(input)
if err != nil {
return err
}
outputStat, err := os.Stat(output) outputStat, err := os.Stat(output)
if err != nil { if err != nil {
if errors.Is(err, os.ErrNotExist) { if errors.Is(err, os.ErrNotExist) {
@ -237,7 +236,13 @@ func (p *processor) processDir(inputDir string) error {
} }
filePath := filepath.Join(inputDir, item.Name()) filePath := filepath.Join(inputDir, item.Name())
if err := p.processFile(filePath); err != nil { allDec := common.GetDecoder(filePath, p.skipNoopDecoder)
if len(allDec) == 0 {
logger.Info("skipping while no suitable decoder", zap.String("source", item.Name()))
continue
}
if err := p.process(filePath, allDec); err != nil {
logger.Error("conversion failed", zap.String("source", item.Name()), zap.Error(err)) logger.Error("conversion failed", zap.String("source", item.Name()), zap.Error(err))
} }
} }