diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-21 17:24:26 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-21 17:24:26 +0100 |
commit | cef4096b39b9543d0fb2ff9867d86d6e12fdf38e (patch) | |
tree | 2229126ff1736198da9d3f94472c2d4cc5fc5a85 /lib/cli | |
parent | a9c96c1afa8c9322645d25684d4171ba540a4d8f (diff) | |
download | gitbook-cef4096b39b9543d0fb2ff9867d86d6e12fdf38e.zip gitbook-cef4096b39b9543d0fb2ff9867d86d6e12fdf38e.tar.gz gitbook-cef4096b39b9543d0fb2ff9867d86d6e12fdf38e.tar.bz2 |
Add cli commands to build ebooks
Diffstat (limited to 'lib/cli')
-rw-r--r-- | lib/cli/index.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/cli/index.js b/lib/cli/index.js index 07c4888..448ea01 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -7,11 +7,38 @@ var Promise = require('../utils/promise'); var PluginsManager = require('../plugins'); var Book = require('../book'); var NodeFS = require('../fs/node'); +var EBookOutput = require('../output/ebook'); var helper = require('./helper'); var Server = require('./server'); var watch = require('./watch'); +function ebookCommand(format) { + return { + name: format + ' [book] [output]', + description: 'generates ebook '+format, + options: [ + helper.options.log + ], + exec: helper.bookCmd(function(book, args, kwargs) { + var output = new EBookOutput(book, { + format: format + }); + + return output.book.parse() + .then(function() { + // Set output folder + if (args[0]) { + output.book.config.set('output', path.resolve(process.cwd(), args[0])); + } + + return output.generate(); + }); + }) + }; +} + + module.exports = { commands: [ @@ -71,6 +98,10 @@ module.exports = { }) }, + ebookCommand('pdf'), + ebookCommand('epub'), + ebookCommand('mobi'), + { name: 'serve [book]', description: 'Build then serve a book from a directory', |