<commit_before>var fs = require('fs');
var path = require('path');

var color = require('colors');
var read = require('read');
var exec = require('child_process').exec;

var $ = require('./helper');

var libDir = __dirname;
var rootDir = path.join(libDir, '../');
var templateDir = path.join(rootDir, 'template') + path.sep;

var templateQ = [{
    name: 'filename',
    prompt: 'html文件名称'.bold.green,
    'default': 'demo'
}, {
    name: 'title',
    prompt: '演讲题目'.bold.green,
    'default': '演讲题目'
}, {
    name: 'subtitle',
    prompt: '副标题'.bold.green,
    'default': ''
}, {
    name: 'speaker',
    prompt: '演讲者'.bold.green,
    'default': '演讲者'
}];
var ppt = module.exports = {
    pdf: function(args) {
        var url = args.splice(0, 1).toString();

        var self = this;
        var output = '';

        for (var i = 0, len = args.length; i < len; i++) {
            switch (args[i]) {
                case '--output':
                    output = args[i + 1] ? args[i + 1] : 8080;
                    i++;
                    break;
            }
        }
        if (url === '') {
            console.log('pdf need a URL'.red);
            console.log('nodeppt pdf 用法：');
            console.log('nodeppt pdf url -o a.pdf: 输出一个pdf');
            return;
        }
        if (output === '') {
            output = 'nodeppt.pdf';
        }
        if (output.slice(-4) !== '.pdf') {
            output += '.pdf';
        }
        var child = exec('phantomjs ' + libDir + '/pdf.js ' + url + ' ' + output);
        // child.stderr.setEncoding('utf8');
        child.stderr.on('data', function(data) {
            console.log('请安装phantomjs：npm install -g phantomjs'.red);
            console.log('nodeppt pdf 功能需要 phantomjs 支持'.red);
        });
        child.stdout.on('data', function(data) {
            console.log(data);
        });
    },
    help: function() {

        console.log('     ________________|'.bold.green + 'nodePPT帮助'.bold.red + '|_______________'.bold.green);
        console.log('    |                                            |'.bold.green);
        console.log('    |   nodeppt start: 启动服务                  |'.bold.green);
        console.log('    |   nodeppt start -p 8000: 启动8000端口      |'.bold.green);
        console.log('    |   nodeppt start -p 8000 -d ./              |'.bold.green);
        console.log('    |   nodeppt create fileName: 创建一个ppt     |'.bold.green);
        console.log('    |   nodeppt pdf url -o a.pdf: 输出一个pdf    |'.bold.green);
        console.log('    |____________________________________________|'.bold.green);
    },
    start: function(args) {
        //启动<commit_msg>help genrate<commit_after>var fs = require('fs');
var path = require('path');

var color = require('colors');
var read = require('read');
var exec = require('child_process').exec;

var $ = require('./helper');

var libDir = __dirname;
var rootDir = path.join(libDir, '../');
var templateDir = path.join(rootDir, 'template') + path.sep;

var templateQ = [{
    name: 'filename',
    prompt: 'html文件名称'.bold.green,
    'default': 'demo'
}, {
    name: 'title',
    prompt: '演讲题目'.bold.green,
    'default': '演讲题目'
}, {
    name: 'subtitle',
    prompt: '副标题'.bold.green,
    'default': ''
}, {
    name: 'speaker',
    prompt: '演讲者'.bold.green,
    'default': '演讲者'
}];
var ppt = module.exports = {
    pdf: function(args) {
        var url = args.splice(0, 1).toString();

        var self = this;
        var output = '';

        for (var i = 0, len = args.length; i < len; i++) {
            switch (args[i]) {
                case '--output':
                    output = args[i + 1] ? args[i + 1] : 8080;
                    i++;
                    break;
            }
        }
        if (url === '') {
            console.log('pdf need a URL'.red);
            console.log('nodeppt pdf 用法：');
            console.log('nodeppt pdf url -o a.pdf: 输出一个pdf');
            return;
        }
        if (output === '') {
            output = 'nodeppt.pdf';
        }
        if (output.slice(-4) !== '.pdf') {
            output += '.pdf';
        }
        var child = exec('phantomjs ' + libDir + '/pdf.js ' + url + ' ' + output);
        // child.stderr.setEncoding('utf8');
        child.stderr.on('data', function(data) {
            console.log('请安装phantomjs：npm install -g phantomjs'.red);
            console.log('nodeppt pdf 功能需要 phantomjs 支持'.red);
        });
        child.stdout.on('data', function(data) {
            console.log(data);
        });
    },
    help: function() {

        console.log('     ________________|'.bold.green + 'nodePPT帮助'.bold.red + '|_______________'.bold.green);
        console.log('    |                                            |'.bold.green);
        console.log('    |   nodeppt start: 启动服务                  |'.bold.green);
        console.log('    |   nodeppt start -p 8000: 启动8000端口      |'.bold.green);
        console.log('    |   nodeppt start -p 8000 -d ./              |'.bold.green);
        console.log('    |   nodeppt create fileName: 创建一个ppt     |'.bold.green);
        console.log('    |   nodeppt pdf url -o a.pdf: 输出一个pdf    |'.bold.green);
        console.log('    |   nodeppt generate path: 输导出html        |'.bold.green);
        console.log('    |____________________________________________|'.bold.green);
    },
    start: function(args) {
        //启动
{'fraction_non_alphanumeric': 0.17119970193740686, 'fraction_numerical': 0.00856929955290611, 'mean_word_length': 1.747697031729785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6460272', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1753, 'n_words': 368}