summaryrefslogtreecommitdiffstats
path: root/lib/cli/index.js
blob: c9a2e8f65722c8166b169d8ca857cc2fcd6444e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var path = require('path');

var PluginsManager = require('../plugins');
var helper = require('./helper');

module.exports = {
    commands: [

        {
            name: 'parse [book]',
            description: 'parse and returns debug information for a book',
            options: [
                helper.options.log
            ],
            exec: helper.bookCmd(function(book) {
                return book.parse()
                .then(function() {
                    book.log.info.ln('');

                    if (book.config.exists()) book.log.info.ln('Configuration:', book.config.path);

                    if (book.isMultilingual()) {
                        book.log.info.ln('Multilingual book detected:', book.langs.path);
                    } else {
                        book.log.info.ln('Readme:', book.readme.path);
                        book.log.info.ln('Summary:', book.summary.path);
                        if (book.glossary.exists()) book.log.info.ln('Glossary:', book.glossary.path);
                    }
                });
            })
        },

        {
            name: 'install [book]',
            description: 'install all plugins dependencies',
            options: [
                helper.options.log
            ],
            exec: helper.bookCmd(function(book, args) {
                var plugins = new PluginsManager(book);
                return plugins.install();
            })
        },

        {
            name: 'build [book] [output]',
            description: 'build a book',
            options: [
                helper.options.log,
                helper.options.format
            ],
            exec: helper.outputCmd(function(output, args, kwargs) {
                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();
                });
            })
        }


    ]
};