@@ -19,12 +19,18 @@ const cli = meow({
19
19
onepunch serve
20
20
Open the presentation in the browser.
21
21
22
- onepunch print
22
+ onepunch print [-i htmlfile] [-o pdffile]
23
23
Print the presentation in a PDF file.
24
24
25
25
OPTIONS
26
26
-n or --name directory_name
27
27
Specify the name of the directory where the project is initialized. Defaults to onepunch-presentation.
28
+
29
+ -i or --input htmlfile
30
+ Specify the HTML file to print, defaults to "index.html".
31
+
32
+ -o or --output pdffile
33
+ Specify the name of the PDF file in output, defaults to "index.pdf".
28
34
29
35
--version
30
36
Display the version number.
@@ -38,6 +44,16 @@ const cli = meow({
38
44
default : 'onepunch-presentation' ,
39
45
alias : 'n' ,
40
46
} ,
47
+ input : {
48
+ type : 'string' ,
49
+ default : 'index.html' ,
50
+ alias : 'i' ,
51
+ } ,
52
+ output : {
53
+ type : 'string' ,
54
+ default : 'index.pdf' ,
55
+ alias : 'o' ,
56
+ } ,
41
57
} ,
42
58
} ) ;
43
59
@@ -49,7 +65,7 @@ switch (cli.input[0]) {
49
65
serve ( ) ;
50
66
break ;
51
67
case 'print' :
52
- print ( ) ;
68
+ print ( cli . flags ) ;
53
69
break ;
54
70
default :
55
71
cli . showHelp ( ) ;
@@ -78,7 +94,9 @@ function init(flags) {
78
94
fs . copySync ( path . resolve ( __dirname , 'template' ) , presentationPath ) ;
79
95
}
80
96
81
- function print ( ) {
97
+ function print ( flags ) {
98
+ const { input, output} = flags ;
99
+
82
100
liveServer . start ( {
83
101
port : 8181 ,
84
102
root : process . cwd ( ) ,
@@ -93,9 +111,9 @@ function print() {
93
111
( async ( ) => {
94
112
const browser = await puppeteer . launch ( ) ;
95
113
const page = await browser . newPage ( ) ;
96
- await page . goto ( ' http://127.0.0.1:8181/index.html' ) ;
114
+ await page . goto ( ` http://127.0.0.1:8181/${ input } ` ) ;
97
115
await page . pdf ( {
98
- path : 'index.pdf' ,
116
+ path : output ,
99
117
width,
100
118
height,
101
119
printBackground : true ,
0 commit comments