forked from freeman-lab/embed-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
41 lines (32 loc) · 664 Bytes
/
cli.js
File metadata and controls
41 lines (32 loc) · 664 Bytes
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
#! /usr/bin/env node
var chalk = require('chalk')
var embed = require('./index')
var minimist = require('minimist')
var argv = minimist(process.argv.slice(2), {
alias: {
o: 'output',
h: 'help'
}
})
var usage = `
Usage:
embed-images <input> -o <output.md>
Options:
--output, -o Output file
--help, -h Show help
`
if (argv.help) {
console.log(usage)
process.exit()
}
if (!argv._[0]) {
error('input file is required')
process.exit()
}
var input = argv._[0]
var output = argv.output
if (output) embed(input, output)
else embed(input)
function error (message) {
console.log('[' + chalk.red('error') + '] ' + message)
}