-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·65 lines (59 loc) · 1.68 KB
/
index.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env node
const path = require('path');
const {
exportResume,
SUPPORTED_OUTPUT_FORMATS,
} = require(__dirname + '/lib');
const DEFAULT_THEME = 'stackoverflow';
// TODO: Auto infer format from filename
// function inferFormatMiddleware(argv) {
// if (!argv.format && argv.output) {
// const ext = argv.output.split('.').pop().toLowerCase();
// if (ext !== argv.output && SUPPORTED_OUTPUT_FORMATS.includes(ext)) {
// argv.format = ext;
// } else {
// argv.format = 'pdf';
// }
// }
// }
function inferOutputMiddleware(argv) {
if (!argv.output && argv.format) {
argv.output = 'resume.' + argv.format;
}
}
function resolveInputMiddleware(argv) {
argv.resume = path.resolve(argv.resume);
}
const argv = require('yargs') // eslint-disable-line
.middleware(resolveInputMiddleware)
// .middleware(inferFormatMiddleware)
.middleware(inferOutputMiddleware)
.usage('$0 [output]', 'Export JSON Resume to human readable formats', (yargs) => {
yargs
.positional('output', {
describe: 'path to output file',
})
.option('format', {
alias: 'f',
choices: SUPPORTED_OUTPUT_FORMATS,
default: 'pdf',
describe: 'output file format'
})
.option('theme', {
alias: 't',
default: DEFAULT_THEME,
describe: 'JSON Resume theme name'
})
}, (argv) => {
return exportResume(argv.resume, argv.output, argv.format, argv.theme);
})
.option('resume', {
alias: 'r',
default: './resume.json',
describe: 'path to JSON Resume file'
})
.option('verbose', {
alias: 'v',
default: false
})
.argv