just another refactor

This commit is contained in:
Daniel Sommer 2017-03-24 22:18:22 +01:00
parent 2673a6e2fa
commit 5cbbe1b7cf
2 changed files with 35 additions and 29 deletions

View file

@ -13,36 +13,42 @@ const util = require('./lib/util');
// generate timestamp
const start = process.hrtime();
util.printLogo();
main();
// general options
commander
.version(app.version)
.usage('[options] <command>')
.option('-c, --concurrency <n>', 'specify concurrency level', os.cpus().length);
// "main"
function main() {
util.printLogo();
parseCLI();
}
// conversion mode
commander
.command('convert <input> <output>')
.description('convert .flac to .mp3 files')
.option('-b, --bitrate <n>', 'specify conversion bitrate', 320)
.action(function (input, output, options) {
console.log('--- CONVERT MODE ---');
console.log('input: ' + input);
console.log('output: ' + output);
console.log('bitrate: ' + commander.options.bitrate);
console.log('conc: ' + commander.concurrency);
});
// sort mode
commander
.command('sort <input> <output>')
.description('sort audio files by tags')
.option('-f, --format <type>', 'specify audio format (\'flac\', \'mp3\')', 'flac')
.action(sort);
// parse command line arguments
commander.parse(process.argv);
// process command line arguments
function parseCLI() {
// general options
commander
.version(app.version)
.usage('[options] <command>')
.option('-c, --concurrency <n>', 'specify concurrency level', os.cpus().length);
// conversion mode
commander
.command('convert <input> <output>')
.description('convert .flac to .mp3 files')
.option('-b, --bitrate <n>', 'specify conversion bitrate', 320)
.action(function (input, output, options) {
console.log('--- CONVERT MODE ---');
console.log('input: ' + input);
console.log('output: ' + output);
console.log('bitrate: ' + commander.options.bitrate);
console.log('conc: ' + commander.concurrency);
});
// sort mode
commander
.command('sort <input> <output>')
.description('sort audio files by tags')
.option('-f, --format <type>', 'specify audio format (\'flac\', \'mp3\')', 'flac')
.action(sort);
// parse command line arguments
commander.parse(process.argv);
}
// sort files
function sort(input, output, options) {

View file

@ -1,6 +1,6 @@
{
"name": "badger-am",
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",
"description": "audio manager",
"author": "Daniel Sommer <daniel.sommer@velvettear.de>",