-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.js
More file actions
41 lines (34 loc) · 872 Bytes
/
cli.js
File metadata and controls
41 lines (34 loc) · 872 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
'use strict';
const updateNotifier = require('update-notifier');
const meow = require('meow');
const pdfoptim = require('.');
const timestamp = Date.now();
const cli = meow(`
Usage
$ pdfoptim [filePath]
Options
--outputFile printer-manual.pdf [Default: optimized-{timestamp}.pdf
Examples
$ pdfoptim essay.pdf
// Optimized PDF created with name optimized-[timestamp].pdf
$ pdfoptim -o essay-optim.pdf essay.pdf
// Optimized PDF created with name essay-optim.pdf
`,
{
flags: {
outputFile: {
type: 'string',
alias: 'o',
default: `optimized-${timestamp}.pdf`
}
}
});
updateNotifier({pkg: cli.pkg}).notify();
const {input: file} = cli;
if (file.length === 0) {
console.error('Specify one path');
process.exit(1);
}
const result = pdfoptim(file[0], {outputFile: cli.flags.outputFile}) ? 0 : 1;
process.exit(result);