-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs.js
More file actions
24 lines (19 loc) · 781 Bytes
/
args.js
File metadata and controls
24 lines (19 loc) · 781 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
const commandLineArgs = require('command-line-args')
const optionDefinitions = [
{ name: 'headers', alias: 'h', type: Boolean },
{ name: 'format', alias: 'f', type: String },
{ name: 'help', type: Boolean },
{ name: 'version', alias: 'v', type: Boolean }
]
const options = commandLineArgs(optionDefinitions, { partial: true });
if (options.help || options.version) {
console.error('csvfmt', require(require('path').join(__dirname, 'package.json')).version)
// console.error('Usage at: https://github.com/pokle/csvfmt')
const fs = require('fs')
const path = require('path')
console.error(String(fs.readFileSync(path.join(__dirname, 'README.md'))));
process.exit(0);
}
options.files = options._unknown || []
delete options._unknown
module.exports = options