Skip to content

Commit 1950f11

Browse files
Use commands without hyphens.
1 parent a52c824 commit 1950f11

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

index.js

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,51 @@ const liveServer = require('live-server');
99
const cli = meow({
1010
description: false,
1111
help: `
12-
Usage
13-
$ one-punch
12+
NAME
13+
onepunch -- create presentation with web technology
1414
15-
Options
16-
--init, -i Initialize a init project
17-
--export, -e Export a PDF file
15+
SYNOPSIS
16+
onepunch init [-n directory_name]
17+
Initialize a presentation.
18+
19+
onepunch serve
20+
Open the presentation in the browser.
21+
22+
onepunch print
23+
Print the presentation in a PDF file.
24+
25+
OPTIONS
26+
-n or --name directory_name
27+
Specify the name of the directory where the project is initialized. Defaults to onepunch-presentation.
28+
29+
--version
30+
Display the version number.
31+
32+
--help
33+
Display the documentation.
1834
`,
1935
flags: {
20-
init: {
21-
type: 'boolean',
22-
default: false,
23-
alias: 'i',
24-
},
25-
print: {
26-
type: 'boolean',
27-
default: false,
28-
alias: 'p',
29-
},
30-
serve: {
31-
type: 'boolean',
32-
default: false,
36+
name: {
37+
type: 'string',
38+
default: 'onepunch-presentation',
39+
alias: 'n',
3340
},
3441
},
3542
});
3643

37-
if (cli.flags.init && !cli.flags.print && !cli.flags.serve) {
38-
init(cli.input[0]);
39-
} else if (cli.flags.print && !cli.flags.init && !cli.flags.serve) {
40-
print();
41-
} else if (cli.flags.serve && !cli.flags.print && !cli.flags.init) {
42-
serve();
43-
} else {
44-
abort('Too many flags used, please double check the command.');
44+
switch (cli.input[0]) {
45+
case 'init':
46+
init(cli.flags);
47+
break;
48+
case 'serve':
49+
serve();
50+
break;
51+
case 'print':
52+
print();
53+
break;
54+
default:
55+
cli.showHelp();
56+
break;
4557
}
4658

4759
function serve() {
@@ -53,8 +65,9 @@ function serve() {
5365
});
5466
}
5567

56-
function init(input) {
57-
const presentationPath = path.resolve(input);
68+
function init(flags) {
69+
const {name} = flags;
70+
const presentationPath = path.resolve(name);
5871
const presentationName = path.basename(presentationPath);
5972

6073
if (fs.existsSync(presentationPath)) {

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ Please note that onepunch makes use of [puppeteer](https://github.com/puppeteer/
1919
### Create a project
2020

2121
```
22-
$ onepunch --init my-presentation
22+
$ onepunch init [-n directory-name]
2323
```
2424

25-
The command above creates the directory `my-presentation` with all the files needed to bootstrap the presentation. The configuration file `onepunch.json` contains configuration parameters, for the moment only the presentation *width* and *height* (in pixels) are available.
25+
The command above creates the directory `directory-name` with all the files needed to bootstrap the presentation. The configuration file `onepunch.json` contains configuration parameters, for the moment only the presentation *width* and *height* (in pixels) are available.
2626

2727
### View the presentation
2828

2929
Inside the project directory, run:
3030

3131
```
32-
$ onepunch --serve
32+
$ onepunch serve
3333
```
3434

3535
The command above starts a local server and opens the browser, use the arrow keys to see the next and previous slides.
@@ -39,7 +39,7 @@ The command above starts a local server and opens the browser, use the arrow key
3939
Inside the project directory, run:
4040

4141
```
42-
$ onepunch --print
42+
$ onepunch print
4343
```
4444

4545
### Create custom styles

template/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Please edit file `index.html` to create your presentation.
33
Start a local server with:
44

55
```
6-
$ onepunch --serve
6+
$ onepunch serve
77
```
88

99
Print the presentation in a PDF file with:
1010

1111
```
12-
$ onepunch --print
12+
$ onepunch print
1313
```

0 commit comments

Comments
 (0)