Skip to content

Commit 0eecc8a

Browse files
Merge pull request #7 from nextbitlabs/flag-i-on-serve
Add flag -i to the serve command
2 parents 493044d + 78d75c4 commit 0eecc8a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const cli = meow({
3131
${chalk.bold('onepunch init')} [${chalk.bold('-n')} ${chalk.italic('directory_name')}]
3232
Initialize a presentation.
3333
34-
${chalk.bold('onepunch serve')}
34+
${chalk.bold('onepunch serve')} [${chalk.bold('-i')} ${chalk.italic('htmlfile')}]
3535
Open the presentation in the browser.
3636
3737
${chalk.bold('onepunch print')} [${chalk.bold('-i')} ${chalk.italic('htmlfile')}] [${chalk.bold('-o')} ${chalk.italic('pdffile')}]
@@ -47,7 +47,7 @@ const cli = meow({
4747
Specify the name of the directory where the project is initialized. Defaults to ${chalk.underline('onepunch-presentation')}.
4848
4949
${chalk.bold('-i')} or ${chalk.bold('--input')} ${chalk.italic('htmlfile')}
50-
Specify the HTML file to print, defaults to ${chalk.underline('index.html')}.
50+
Specify the HTML file to serve or print, defaults to ${chalk.underline('index.html')}.
5151
5252
${chalk.bold('-o')} or ${chalk.bold('--output')} ${chalk.italic('pdffile')}
5353
Specify the name of the PDF file in output, defaults to ${chalk.underline('index.pdf')}.
@@ -104,7 +104,7 @@ switch (cli.input[0]) {
104104
init(cli.flags);
105105
break;
106106
case 'serve':
107-
serve();
107+
serve(cli.flags);
108108
break;
109109
case 'print':
110110
print(cli.flags);
@@ -117,11 +117,11 @@ switch (cli.input[0]) {
117117
break;
118118
}
119119

120-
function serve() {
120+
function serve(flags) {
121121
liveServer.start({
122122
port: 8180,
123123
root: process.cwd(),
124-
open: true,
124+
open: `/${flags.input}`,
125125
logLevel: 1,
126126
});
127127
}

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ The command above creates the directory `directory-name` with all the files need
3535
Inside the project directory, run:
3636

3737
```sh
38-
$ onepunch serve
38+
$ onepunch serve [-i htmlfile]
3939
```
4040

4141
The command above starts a local server and opens the browser, use the arrow keys to see the next and previous slides.
42+
Flag `-i` (or `--input`) specifies the HTML file to open, it defaults to "index.html".
4243

4344
### Print the PDF
4445

0 commit comments

Comments
 (0)