diff --git a/README.md b/README.md index 19787a9..1deb9b4 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ Use the applicable instructions for the interface of your choice (currently limi The [command-line interface](http://en.wikipedia.org/wiki/Command-line_interface) does not have a graphical component and is ideal for automation purposes and headless machines. The interface can run using a sequence of series addresses (the site address containing the chapter listing), or with a batch-mode source file. The `mangarack --help` command will produce the following output: Usage: mangarack [options] - + Options: - + -h, --help output usage information -V, --version output the version number -a, --animation Disable image animation framing. @@ -120,7 +120,7 @@ Download *Aoi Hana* from *MangaFox* and *Citrus* from *Batoto* to the current wo * `-o or --output ` sets the output directory (defaults to *current work directory*). * `-s or --source ` sets the batch-mode source file (defaults to *MangaRack.txt*) * `-t or --transform ` sets an overriding image format transformation (e.g. *jpg*). -* `-w or --workers ` sets the maximum concurrency (defaults to the machines cores). +* `-w or --workers ` sets the maximum concurrency (defaults to # of cores, up to 4). ## Developers diff --git a/lib/cli/index.js b/lib/cli/index.js index 77f1bf6..be3c606 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -13,7 +13,7 @@ var parse = require('./parse'); var options = parse(process.argv); _initialize(options, options.source || defaultSource, function(err, tasks) { if (err) return console.error(err.stack || err); - var maximum = options.workers || os.cpus().length; + var maximum = options.workers || _getNumberOfCores(); nodejs(tasks, maximum).on('data', function(data) { console.log(_pretty(data)); }).on('error', function(err) { @@ -38,6 +38,16 @@ function _calculate(timeInMs) { return '(' + hours + ':' + minutes + ':' + seconds + ')'; } +/** + * Gets the number of cores, limited to a maximum of 4. + * @returns {number} + */ +function _getNumberOfCores() { + var numberOfCores = os.cpus().length; + if (numberOfCores > 4) return 4; + return numberOfCores; +} + /** * Initializes the tasks. * @private diff --git a/package.json b/package.json index bbceebc..245227c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ ], "name": "mangarack", "repository": "git://github.com/Deathspike/mangarack.js.git", - "version": "3.1.6", + "version": "3.1.7", "bin": { "mangarack": "./bin/mangarack" },