added cli param '-n, --no-confirm'
This commit is contained in:
parent
ac49233bf9
commit
dcd91ce8bf
4 changed files with 36 additions and 22 deletions
|
@ -19,7 +19,8 @@ function badger() {
|
|||
commander
|
||||
.version(app.version)
|
||||
.usage('[options] <command>')
|
||||
.option('-c, --concurrency <n>', 'specify concurrency level', os.cpus().length);
|
||||
.option('-c, --concurrency <n>', 'specify concurrency level', os.cpus().length)
|
||||
.option('-n, --no-confirm', 'disable confirmation messages');
|
||||
// conversion
|
||||
commander
|
||||
.command('convert <input> <output>')
|
||||
|
@ -54,6 +55,7 @@ function convert(input, output, options) {
|
|||
input: path.normalize(input),
|
||||
output: path.normalize(output),
|
||||
concurrency: commander.concurrency || os.cpus().length,
|
||||
confirm: commander.confirm || false,
|
||||
bitrate: options.bitrate || 320,
|
||||
format: options.format || '.flac'
|
||||
}, function (err, time) {
|
||||
|
@ -67,7 +69,7 @@ function sort(input, output, options) {
|
|||
input: path.normalize(input),
|
||||
output: path.normalize(output),
|
||||
concurrency: commander.concurrency || os.cpus().length,
|
||||
bitrate: options.bitrate || 320,
|
||||
confirm: commander.confirm || false,
|
||||
format: options.format || '.flac'
|
||||
}, function (err, skipped, time) {
|
||||
if (!skipped || skipped.length === 0) {
|
||||
|
@ -103,6 +105,7 @@ function scan(input, options) {
|
|||
audio.batchScan({
|
||||
input: path.normalize(input),
|
||||
concurrency: commander.concurrency || os.cpus().length,
|
||||
confirm: commander.confirm || false,
|
||||
format: options.format || '.flac'
|
||||
}, function (err, missing, time) {
|
||||
if (!missing || missing.length === 0) {
|
||||
|
|
28
lib/audio.js
28
lib/audio.js
|
@ -19,12 +19,16 @@ function batchConvert(config, callback) {
|
|||
// display info, prompt user and create progressbar
|
||||
function (files, waterfallCallback) {
|
||||
console.log(files.length + ' files found after ' + util.getTimeDiff(timestamp) + ' seconds');
|
||||
cli.askForConfirmation('start conversion now?', ['yes', 'y'], function (err) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
if (config.confirm) {
|
||||
cli.askForConfirmation('start conversion now?', ['yes', 'y'], function (err) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
waterfallCallback(null, files, cli.createProgressBar(files.length));
|
||||
});
|
||||
} else {
|
||||
waterfallCallback(null, files, cli.createProgressBar(files.length));
|
||||
});
|
||||
}
|
||||
},
|
||||
// process each file
|
||||
function (files, bar, waterfallCallback) {
|
||||
|
@ -92,12 +96,16 @@ function batchExtract(config, callback) {
|
|||
// display info, prompt user and create progressbar
|
||||
function (files, waterfallCallback) {
|
||||
console.log(files.length + ' files found after ' + util.getTimeDiff(timestamp) + ' seconds');
|
||||
cli.askForConfirmation('start artwork extraction now?', ['yes', 'y'], function (err) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
if (config.confirm) {
|
||||
cli.askForConfirmation('start artwork extraction now?', ['yes', 'y'], function (err) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
waterfallCallback(null, files, cli.createProgressBar(files.length));
|
||||
});
|
||||
}
|
||||
},
|
||||
// process each file
|
||||
function (files, bar, waterfallCallback) {
|
||||
|
|
21
lib/util.js
21
lib/util.js
|
@ -18,12 +18,16 @@ function batchSort(config, callback) {
|
|||
// display info, prompt user and create progressbar
|
||||
function (files, waterfallCallback) {
|
||||
console.log(files.length + ' files found after ' + getTimeDiff(timestamp) + ' seconds');
|
||||
cli.askForConfirmation('start sorting now?', ['yes', 'y'], function (err) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
if (config.confirm) {
|
||||
cli.askForConfirmation('start sorting now?', ['yes', 'y'], function (err) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
waterfallCallback(null, files, cli.createProgressBar(files.length));
|
||||
});
|
||||
} else {
|
||||
waterfallCallback(null, files, cli.createProgressBar(files.length));
|
||||
});
|
||||
}
|
||||
},
|
||||
// process each file
|
||||
function (files, bar, waterfallCallback) {
|
||||
|
@ -125,9 +129,9 @@ function getPathByMetadata(source, output, metadata, callback) {
|
|||
fileName += metadata.title.trim();
|
||||
}
|
||||
// append extension
|
||||
fileName += replaceIllegalChars(path.extname(source)).trim();
|
||||
// join directory and name
|
||||
callback(null, path.join(filePath, fileName));
|
||||
fileName += path.extname(source).trim();
|
||||
// replace illegal chars, join directory and name
|
||||
callback(null, path.join(filePath, replaceIllegalChars(fileName)));
|
||||
}
|
||||
|
||||
// fill a string beginning from the front
|
||||
|
@ -140,7 +144,6 @@ function frontFill(string, fill, length) {
|
|||
|
||||
// replace illegal characters
|
||||
function replaceIllegalChars(string) {
|
||||
// TODO: check function, seems like it doesn't work at all
|
||||
return string.replace(/[/\\:*?"<>|]/g, '-');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "badger-am",
|
||||
"version": "0.6.1",
|
||||
"version": "0.7.0",
|
||||
"license": "MIT",
|
||||
"description": "audio manager",
|
||||
"author": "Daniel Sommer <daniel.sommer@velvettear.de>",
|
||||
|
|
Loading…
Reference in a new issue