-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
36 lines (34 loc) · 989 Bytes
/
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
#!/usr/bin/env node
const yargs = require("yargs");
const {
findwordcategory
} = require('.')
const usage = "\nUsage: persianwordscategory <word> persian word to get category";
const help = "\nUsage: persianwordscategory <word> persian word to get category .\n\nuse --help for more info";
const options = yargs
.usage(usage)
.option("r", {
alias: "raw",
describe: "return raw data",
type: "boolean",
demandOption: false
})
.help(true)
.argv;
if (yargs.argv._[0] == null) {
console.log(help);
return;
}
console.log('> category of : "' + yargs.argv._[0] + "\"");
var category = findwordcategory(yargs.argv._[0]);
if (typeof category != 'undefined') {
if (yargs.argv.r == true) {
console.log(category);
return;
}
console.log('> totaL catagories : "' + category.length + "\"");
console.log('> categories : ');
console.log(category.join(','));
} else {
console.log('no category found');
}