2 Commits

Author SHA1 Message Date
鲁树人
b2ef27761f chore: bump version to v0.2.8 2024-10-25 23:03:34 +09:00
鲁树人
7f7cb66fe5 fix #103: incorrect output path when input is a single file 2024-10-25 23:02:32 +09:00

View File

@@ -34,7 +34,7 @@ import (
"unlock-music.dev/cli/internal/utils" "unlock-music.dev/cli/internal/utils"
) )
var AppVersion = "v0.2.7" var AppVersion = "v0.2.8"
var logger, _ = logging.NewZapLogger() // TODO: inject logger to application, instead of using global logger var logger, _ = logging.NewZapLogger() // TODO: inject logger to application, instead of using global logger
@@ -121,13 +121,16 @@ func appMain(c *cli.Context) (err error) {
return err return err
} }
if output == "" { var inputDir string
// Default to where the input is
if inputStat.IsDir() { if inputStat.IsDir() {
output = input inputDir = input
} else { } else {
output = path.Dir(input) inputDir = path.Dir(input)
} }
if output == "" {
// Default to where the input dir is
output = inputDir
} }
outputStat, err := os.Stat(output) outputStat, err := os.Stat(output)
@@ -152,7 +155,7 @@ func appMain(c *cli.Context) (err error) {
} }
proc := &processor{ proc := &processor{
inputDir: input, inputDir: inputDir,
outputDir: output, outputDir: output,
skipNoopDecoder: c.Bool("skip-noop"), skipNoopDecoder: c.Bool("skip-noop"),
removeSource: c.Bool("remove-source"), removeSource: c.Bool("remove-source"),