forked from ksky521/nodeppt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodeppt
executable file
·124 lines (102 loc) · 3.47 KB
/
nodeppt
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var nodePPT = require('../lib/nodePPT');
var versions = require('../package').version;
var program = require('commander');
var ipv4 = require('ipv4');
program
.version(versions);
program
.command('create')
.usage('[filename] [option]')
.description('create a slide')
.option('-d, --dir [path]','set slide file destination path')
.action(function (filename, options) {
if(typeof filename === 'object'){
console.log('ERROR: please input filename!'.bold.red);
this.outputHelp();
return;
}
nodePPT.create(filename, options)
}).on('--help', function() {
console.log(' Examples:');
console.log();
console.log(' nodeppt create myslide');
console.log(' nodeppt create myslide -d D:/webppt');
console.log();
});
program
.command('generate')
.usage('[file_path] [save_path]')
.description('export html file')
.option('-o, --output [path]', 'output path')
.option('-a, --all [false]','output all style(include js,css) file', false)
.action(function (cmd, options){
var filename = '';
var shouldAll = false;
var output = '';
if(typeof cmd === 'string'){
filename = cmd;
shouldAll = options.all;
output = options.output;
}else if(typeof cmd === 'object'){
shouldAll = cmd.all;
output = cmd.output;
}
nodePPT.generate(filename, output, shouldAll);
})
.on('--help', function() {
console.log(' Examples:');
console.log();
console.log(' nodeppt generate D:/webppt/demo.md -o D:/output');
console.log(' nodeppt generate D:/webppt/ -o D:/output -a');
console.log();
});
program
.command('start')
.description('start local sever show slide')
.option('-d, --dir [dir]', 'set slide path', '')
.option('-p, --port [port]', 'set server port ', 8080)
.option('-c, --controller [socket]', 'support websocket mutil screen controller')
.option('-H, --host [host]', 'set host address', ipv4 || '0.0.0.0')
.option('-w, --watch', 'livereload')
.action(function (cmd){
if(typeof cmd !== 'object'){
this.outputHelp();
return;
}
nodePPT.start(cmd)
})
.on('--help', function() {
console.log(' Examples:');
console.log();
console.log(' nodeppt start -d D:/webppt -p 8080');
console.log(' nodeppt start -d D:/webppt -c socket');
console.log();
});
program
.command('pdf')
.usage('[http_url] [save_path.pdf]')
.description('export pdf file')
.action(function (http_url, save_path) {
if(typeof http_url !== 'string' || typeof save_path !== 'string'){
console.log('ERROR: pdf need a URL'.bold.red);
this.outputHelp();
return;
}
nodePPT.pdf([http_url,save_path])
})
.on('--help', function() {
console.log(' Examples:');
console.log();
console.log(' nodeppt pdf http://127.0.0.1:8080/md/demo.md demo.pdf\n');
console.log(' Notice: '.bold.red + 'should install phantomjs before');
console.log(' npm install -g phantomjs');
console.log();
});
program.parse(process.argv);
if (!program.args[0]) {
process.stdout.write(program.helpInformation());
program.emit('--help');
}