-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.js
executable file
·45 lines (42 loc) · 873 Bytes
/
bin.js
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
#!/usr/bin/env node
const yargs = require('yargs')
const {
buildSite,
newEntry,
rssFeed
} = require('.')
yargs
.command({
command: 'build',
description: '',
handler: async () => {
await buildSite()
}
})
.command({
command: 'rss',
description: '',
handler: async () => {
await rssFeed()
}
})
.command({
command: 'new-entry [name]',
description: '',
builder: (yargs) => {
yargs.positional('name', {
describe: 'The filename for the new entry. Used as the URL slug.',
type: 'string',
default: new Date().toISOString()
})
yargs.option('title', {
describe: 'The title of the entry.'
})
},
handler: async ({ name, title }) => {
await newEntry({ name, title })
}
})
.alias('help', 'h')
.wrap(yargs.terminalWidth())
.parse()