-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·39 lines (36 loc) · 1.14 KB
/
cli.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
#!/usr/bin/env node
const { argv } = require('yargs')
.usage('$0 <input>', 'Translate input file')
.positional('input', {
describe: 'Input JSON file',
type: 'string',
alias: 'i'
})
.string('output')
.alias('output', 'o')
.describe('output', 'Output JSON file')
.default('output', 'output.json')
.string('to')
.alias('to', 't')
.describe('to', 'Translate to language')
.string('from')
.alias('from', 'f')
.describe('from', 'Translate from language')
.string('apiKey')
.describe('apiKey', 'Cloud IBM Language Translator API KEY')
.string('apiUrl')
.describe('apiUrl', 'Cloud IBM Language Translator API URL')
.boolean('ignoreExistingFile')
.default('ignoreExistingFile', false)
.describe('ignoreExistingFile', 'Ignore values already translate in destination file (if exists)')
.demandOption(['input', 'to', 'apiKey', 'apiUrl'])
const Translator = require('.')
const ora = require('ora')
async function main () {
const spinner = ora('Initializing... 📚').start()
const translator = new Translator({ ...argv, spinner })
await translator.run()
spinner.succeed('All done! 😆')
spinner.stop()
}
main()