@microlink/cli
Version:
Interacting with Microlink API from your terminal.
36 lines (28 loc) • 726 B
JavaScript
const mri = require('mri')
const { hasColorizedOutput, parseHeaders } = require('./util')
const parsed = mri(process.argv.slice(2), {
alias: { H: 'header' },
boolean: ['copy', 'json', 'json-full', 'pretty'],
string: ['header'],
default: {
apiKey: process.env.MICROLINK_API_KEY,
pretty: hasColorizedOutput(),
copy: false,
json: false,
'json-full': false
}
})
const { _, header, 'api-key': apiKey, ...flags } = parsed
if (apiKey !== undefined) flags.apiKey = apiKey
const headers = parseHeaders(header)
module.exports = {
flags,
headers,
input: _,
showHelp: () => {
console.log(require('./help'))
process.exit(0)
}
}
module.exports.parseHeaders = parseHeaders