Socket
Socket
Sign inDemoInstall

leximaven

Package Overview
Dependencies
317
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.4 to 3.0.0

.gitconfig

2

bin/commands/datamuse/get.js

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var chalk=require('chalk');var http=require('good-guy-http')();var noon=require('noon');var ora=require('ora');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='get <condition>';exports.desc='Datamuse query';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},max:{alias:'m',desc:'Maximum number of results, 1 to 1000',default:5,type:'number'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.dmuse.date.stamp);var hours=df.differenceInHours(new Date(),stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitDmuse(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={dmuse:{max:argv.m}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Datamuse');var ccont=[];ccont.push(argv.condition);if(argv._.length>1){for(var i=0;i<=argv._.length-1;i++){if(argv._[i]!=='datamuse'&&argv._[i]!=='dmuse'&&argv._[i]!=='dm'&&argv._[i]!=='get'){ccont.push(argv._[i]);}}}var prefix='http://api.datamuse.com/words?';var conditions='max='+config.dmuse.max+'&';for(var _i=0;_i<=ccont.length-1;_i++){conditions=conditions+'&'+ccont[_i];}var url=''+prefix+conditions;url=encodeURI(url);var tags={n:'noun',adj:'adjective',adv:'adverb',syn:'synonym'};var tofile={type:'datamuse',source:'http://datamuse.com/api',url:url};var ctstyle=_.get(chalk,theme.content.style);var spinner=ora({text:''+chalk.bold.cyan('Loading results...'),spinner:'dots8',color:'yellow'});http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.dmuse.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var resp=JSON.parse(response.body);spinner.stop();spinner.clear();for(var _i2=0;_i2<=resp.length-1;_i2++){var item=resp[_i2];themes.label(theme,'right','Match',item.word+' ');tofile[['match'+_i2]]=item.word;if(item.tags!==undefined&&item.tags!==[]){themes.label(theme,'right','Tag');for(var j=0;j<=item.tags.length-1;j++){if(j===item.tags.length-1){process.stdout.write(ctstyle(''+tags[item.tags[j]]));tofile[['tags'+j]]=tags[item.tags[j]];}else process.stdout.write(ctstyle(tags[item.tags[j]]+', '));}console.log('');}}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, reset usage limits.\n'+config.dmuse.date.remain+'/'+config.dmuse.date.limit+' requests remaining today.'):console.log(config.dmuse.date.remain+'/'+config.dmuse.date.limit+' requests remaining today, will reset in '+(23-hours)+' hours, '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached today\'s usage limit of '+config.dmuse.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var chalk=require('chalk');var http=require('good-guy-http')();var noon=require('noon');var ora=require('ora');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='get <condition>';exports.desc='Datamuse query';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},max:{alias:'m',desc:'Maximum number of results, 1 to 1000',default:5,type:'number'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.dmuse.date.stamp);var hours=df.differenceInHours(new Date(),stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitDmuse(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={dmuse:{max:argv.m}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Datamuse');var ccont=[];ccont.push(argv.condition);if(argv._.length>1){for(var i=0;i<=argv._.length-1;i++){if(argv._[i]!=='datamuse'&&argv._[i]!=='dmuse'&&argv._[i]!=='dm'&&argv._[i]!=='get'){ccont.push(argv._[i]);}}}var prefix='http://api.datamuse.com/words?';var conditions='max='+config.dmuse.max+'&';for(var _i=0;_i<=ccont.length-1;_i++){conditions=conditions+'&'+ccont[_i];}var url=''+prefix+conditions;url=encodeURI(url);var tags={n:'noun',adj:'adjective',adv:'adverb',syn:'synonym'};var tofile={type:'datamuse',source:'http://datamuse.com/api',url:url};var ctstyle=_.get(chalk,theme.content.style);var spinner=ora({text:''+chalk.bold.cyan('Loading results...'),spinner:'dots8',color:'yellow'});http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.dmuse.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var resp=JSON.parse(response.body);spinner.stop();spinner.clear();for(var _i2=0;_i2<=resp.length-1;_i2++){var item=resp[_i2];themes.label(theme,'right','Match',item.word+' ');tofile[['match'+_i2]]=item.word;if(item.tags!==undefined&&item.tags!==[]){themes.label(theme,'right','Tag');for(var j=0;j<=item.tags.length-1;j++){if(j===item.tags.length-1){process.stdout.write(ctstyle(''+tags[item.tags[j]]));tofile[['tags'+j]]=tags[item.tags[j]];}else process.stdout.write(ctstyle(tags[item.tags[j]]+', '));}console.log('');}}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, reset usage limits.\n'+config.dmuse.date.remain+'/'+config.dmuse.date.limit+' requests remaining today.'):console.log(config.dmuse.date.remain+'/'+config.dmuse.date.limit+' requests remaining today, will reset in '+(23-hours)+' hours, '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached today\'s usage limit of '+config.dmuse.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../themes');var tools=require('../tools');var _=require('lodash');var df=require('date-fns');var chalk=require('chalk');var http=require('good-guy-http')();var noon=require('noon');var xml2js=require('xml2js');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='onelook <word>';exports.aliases=['one','ol'];exports.desc='Onelook definitions';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},links:{alias:'l',desc:'Include resource links',default:false,type:'boolean'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var checkStamp=tools.limitOnelook(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];var stamp=new Date(config.onelook.date.stamp);var hours=df.differenceInHours(new Date(),stamp);var minutes=df.differenceInMinutes(new Date(),stamp);if(proceed){(function(){var userConfig={onelook:{links:argv.l}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Onelook');var acont=[];acont.push(argv.word);if(argv._.length>1){for(var i=0;i<=argv._.length-1;i++){if(argv._[i]!=='onelook'&&argv._[i]!=='one'&&argv._[i]!=='ol')acont.push(argv._[i]);}}var url='http://onelook.com/?xml=1&w='+acont.join('+');url=encodeURI(url);var tofile={type:'onelook',source:'http://www.onelook.com',url:url};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.onelook.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var body=response.body;var parser=new xml2js.Parser();parser.parseString(body,function(err,result){if(!err){var resp=result.OLResponse;var phrase=resp.OLPhrases[0];var similar=resp.OLSimilar[0];var quickdef=resp.OLQuickDef;var resources=resp.OLRes;themes.label(theme,'down','Definition');if(Array.isArray(quickdef)&&quickdef.length>1){for(var _i=0;_i<=quickdef.length-1;_i++){var item=quickdef[_i];item=item.replace(/&lt;|&gt;|\n|\/i/g,'');item=item.replace(/i"/g,'"');console.log(ctstyle(item));tofile[['definition'+_i]]=item;}}else{var definition=quickdef[0].replace(/&lt;|&gt;|\n|\/i/g,'');console.log(ctstyle(definition));tofile.definition=definition;}if(phrase){var phrases=phrase.replace(/\n/g,'');themes.label(theme,'down','Phrases',phrases);tofile.phrase=phrases;}if(similar){var sim=similar.replace(/\n/g,'');themes.label(theme,'down','Similar',sim);tofile.sim=sim;}if(config.onelook.links){themes.label(theme,'down','Resources');for(var _i2=0;_i2<=resources.length-1;_i2++){var _item=resources[_i2];var res=tools.arrToStr(_item.OLResName).replace(/\n/g,'');var link=tools.arrToStr(_item.OLResLink).replace(/\n/g,'');var home=tools.arrToStr(_item.OLResHomeLink).replace(/\n/g,'');themes.label(theme,'right',res,link);tofile[['res'+_i2]]=res;tofile[['link'+_i2]]=link;tofile[['home'+_i2]]=home;}}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage){if(reset){console.log('Timestamp expired, reset usage limits.');console.log(config.onelook.date.remain+'/'+config.onelook.date.limit+' requests remaining today.');}else console.log(config.onelook.date.remain+'/'+config.onelook.date.limit+' requests remaining today, will reset in '+(23-hours)+' hours, '+(59-minutes)+' minutes.');}}else{throw new Error(err);}});}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached today\'s usage limit of '+config.onelook.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../themes');var tools=require('../tools');var _=require('lodash');var df=require('date-fns');var chalk=require('chalk');var http=require('good-guy-http')();var noon=require('noon');var xml2js=require('xml2js');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='onelook <word>';exports.aliases=['one','ol'];exports.desc='Onelook definitions';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},links:{alias:'l',desc:'Include resource links',default:false,type:'boolean'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var checkStamp=tools.limitOnelook(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];var stamp=new Date(config.onelook.date.stamp);var hours=df.differenceInHours(new Date(),stamp);var minutes=df.differenceInMinutes(new Date(),stamp);if(proceed){var userConfig={onelook:{links:argv.l}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Onelook');var acont=[];acont.push(argv.word);if(argv._.length>1){for(var i=0;i<=argv._.length-1;i++){if(argv._[i]!=='onelook'&&argv._[i]!=='one'&&argv._[i]!=='ol')acont.push(argv._[i]);}}var url='http://onelook.com/?xml=1&w='+acont.join('+');url=encodeURI(url);var tofile={type:'onelook',source:'http://www.onelook.com',url:url};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.onelook.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var body=response.body;var parser=new xml2js.Parser();parser.parseString(body,function(err,result){if(!err){var resp=result.OLResponse;var phrase=resp.OLPhrases[0];var similar=resp.OLSimilar[0];var quickdef=resp.OLQuickDef;var resources=resp.OLRes;themes.label(theme,'down','Definition');if(Array.isArray(quickdef)&&quickdef.length>1){for(var _i=0;_i<=quickdef.length-1;_i++){var item=quickdef[_i];item=item.replace(/&lt;|&gt;|\n|\/i/g,'');item=item.replace(/i"/g,'"');console.log(ctstyle(item));tofile[['definition'+_i]]=item;}}else{var definition=quickdef[0].replace(/&lt;|&gt;|\n|\/i/g,'');console.log(ctstyle(definition));tofile.definition=definition;}if(phrase){var phrases=phrase.replace(/\n/g,'');themes.label(theme,'down','Phrases',phrases);tofile.phrase=phrases;}if(similar){var sim=similar.replace(/\n/g,'');themes.label(theme,'down','Similar',sim);tofile.sim=sim;}if(config.onelook.links){themes.label(theme,'down','Resources');for(var _i2=0;_i2<=resources.length-1;_i2++){var _item=resources[_i2];var res=tools.arrToStr(_item.OLResName).replace(/\n/g,'');var link=tools.arrToStr(_item.OLResLink).replace(/\n/g,'');var home=tools.arrToStr(_item.OLResHomeLink).replace(/\n/g,'');themes.label(theme,'right',res,link);tofile[['res'+_i2]]=res;tofile[['link'+_i2]]=link;tofile[['home'+_i2]]=home;}}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage){if(reset){console.log('Timestamp expired, reset usage limits.');console.log(config.onelook.date.remain+'/'+config.onelook.date.limit+' requests remaining today.');}else console.log(config.onelook.date.remain+'/'+config.onelook.date.limit+' requests remaining today, will reset in '+(23-hours)+' hours, '+(59-minutes)+' minutes.');}}else{throw new Error(err);}});}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached today\'s usage limit of '+config.onelook.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='combine <query>';exports.aliases=['comb','portmanteau'];exports.desc='Rhymebrain portmanteaus';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},lang:{alias:'l',desc:'ISO 639-1 language code',default:'en',type:'string'},max:{alias:'m',desc:'Max results to return',default:5,type:'number'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.rbrain.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitRbrain(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={rbrain:{combine:{lang:argv.l,max:argv.m}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Rhymebrain');var query=argv.query;var task='Portmanteaus';var prefix='http://rhymebrain.com/talk?function=get';var uri=''+prefix+task+'&word='+query+'&';var pcont=[];pcont.push('lang='+config.rbrain.combine.lang+'&');pcont.push('maxResults='+config.rbrain.combine.max+'&');var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down',task);var tofile={type:'portmanteau',source:'http://rhymebrain.com',url:url};http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.rbrain.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right',item.source,item.combined);tofile[['set'+i]]=item.source;tofile[['portmanteau'+i]]=item.combined;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, reset usage limits.\n'+config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour.'):console.log(config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.rbrain.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='combine <query>';exports.aliases=['comb','portmanteau'];exports.desc='Rhymebrain portmanteaus';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},lang:{alias:'l',desc:'ISO 639-1 language code',default:'en',type:'string'},max:{alias:'m',desc:'Max results to return',default:5,type:'number'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.rbrain.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitRbrain(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={rbrain:{combine:{lang:argv.l,max:argv.m}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Rhymebrain');var query=argv.query;var task='Portmanteaus';var prefix='http://rhymebrain.com/talk?function=get';var uri=''+prefix+task+'&word='+query+'&';var pcont=[];pcont.push('lang='+config.rbrain.combine.lang+'&');pcont.push('maxResults='+config.rbrain.combine.max+'&');var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down',task);var tofile={type:'portmanteau',source:'http://rhymebrain.com',url:url};http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.rbrain.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right',item.source,item.combined);tofile[['set'+i]]=item.source;tofile[['portmanteau'+i]]=item.combined;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, reset usage limits.\n'+config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour.'):console.log(config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.rbrain.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='info <word>';exports.desc='Rhymebrain word info';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},lang:{alias:'l',desc:'ISO 639-1 language code',default:'en',type:'string'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.rbrain.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitRbrain(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={rbrain:{info:{lang:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Rhymebrain');var word=argv.word;var task='WordInfo';var prefix='http://rhymebrain.com/talk?function=get';var uri=''+prefix+task+'&word='+word+'&lang='+config.rbrain.info.lang;var url=encodeURI(uri);themes.label(theme,'down','Word Info');var tofile={type:'word info',source:'http://rhymebrain.com',url:url};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.rbrain.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var info=JSON.parse(response.body);themes.label(theme,'right','Arpabet',info.pron);themes.label(theme,'right','IPA',info.ipa);themes.label(theme,'right','Syllables',info.syllables);tofile.arpabet=info.pron;tofile.ipa=info.ipa;tofile.syllables=info.syllables;var flags=[];if(info.flags.match(/a/)){flags.push(ctstyle('['+chalk.red.bold('Offensive')+']'));tofile.offensive=true;}if(info.flags.match(/b/)){flags.push(ctstyle('[Found in dictionary]'));tofile.dict=true;}if(info.flags.match(/c/)){flags.push(ctstyle('[Trusted pronunciation, not generated]'));tofile.trusted=true;}themes.label(theme,'right','Word Flags',flags.join(''));if(argv.o)tools.outFile(argv.o,argv.f,tofile);reset?console.log('Timestamp expired, reset usage limits.\n'+config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour.'):console.log(config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.rbrain.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='info <word>';exports.desc='Rhymebrain word info';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},lang:{alias:'l',desc:'ISO 639-1 language code',default:'en',type:'string'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.rbrain.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitRbrain(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={rbrain:{info:{lang:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Rhymebrain');var word=argv.word;var task='WordInfo';var prefix='http://rhymebrain.com/talk?function=get';var uri=''+prefix+task+'&word='+word+'&lang='+config.rbrain.info.lang;var url=encodeURI(uri);themes.label(theme,'down','Word Info');var tofile={type:'word info',source:'http://rhymebrain.com',url:url};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.rbrain.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var info=JSON.parse(response.body);themes.label(theme,'right','Arpabet',info.pron);themes.label(theme,'right','IPA',info.ipa);themes.label(theme,'right','Syllables',info.syllables);tofile.arpabet=info.pron;tofile.ipa=info.ipa;tofile.syllables=info.syllables;var flags=[];if(info.flags.match(/a/)){flags.push(ctstyle('['+chalk.red.bold('Offensive')+']'));tofile.offensive=true;}if(info.flags.match(/b/)){flags.push(ctstyle('[Found in dictionary]'));tofile.dict=true;}if(info.flags.match(/c/)){flags.push(ctstyle('[Trusted pronunciation, not generated]'));tofile.trusted=true;}themes.label(theme,'right','Word Flags',flags.join(''));if(argv.o)tools.outFile(argv.o,argv.f,tofile);reset?console.log('Timestamp expired, reset usage limits.\n'+config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour.'):console.log(config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.rbrain.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='rhyme <word>';exports.aliases=['rh'];exports.desc='Rhymebrain rhymes';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},lang:{alias:'l',desc:'ISO 639-1 language code',default:'en',type:'string'},max:{alias:'m',desc:'Max results to return',default:5,type:'number'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.rbrain.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitRbrain(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={rbrain:{rhyme:{lang:argv.l,max:argv.m}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Rhymebrain');var word=argv.word;var task='Rhymes';var prefix='http://rhymebrain.com/talk?function=get';var uri=''+prefix+task+'&word='+word+'&';var pcont=[];pcont.push('lang='+config.rbrain.rhyme.lang+'&');pcont.push('maxResults='+config.rbrain.rhyme.max+'&');var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'rhyme',source:'http://rhymebrain.com',url:url};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.rbrain.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);var lcont=[];for(var i=0;i<=list.length-1;i++){lcont.push(list[i].word);}lcont.sort(function(a,b){if(a<b)return-1;if(a>b)return 1;return 0;});var rcont=[];for(var j=0;j<=lcont.length-1;j++){var item=lcont[j];rcont.push(ctstyle(item));item.score>=300?tofile[['hiscore'+j]]=item:tofile[['rhyme'+j]]=item;}rcont.sort();themes.label(theme,'right',task,rcont.join(', '));if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, reset usage limits.\n'+config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour.'):console.log(config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.rbrain.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='rhyme <word>';exports.aliases=['rh'];exports.desc='Rhymebrain rhymes';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},lang:{alias:'l',desc:'ISO 639-1 language code',default:'en',type:'string'},max:{alias:'m',desc:'Max results to return',default:5,type:'number'}};exports.handler=function(argv){tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.rbrain.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitRbrain(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={rbrain:{rhyme:{lang:argv.l,max:argv.m}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Rhymebrain');var word=argv.word;var task='Rhymes';var prefix='http://rhymebrain.com/talk?function=get';var uri=''+prefix+task+'&word='+word+'&';var pcont=[];pcont.push('lang='+config.rbrain.rhyme.lang+'&');pcont.push('maxResults='+config.rbrain.rhyme.max+'&');var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'rhyme',source:'http://rhymebrain.com',url:url};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.rbrain.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);var lcont=[];for(var i=0;i<=list.length-1;i++){lcont.push(list[i].word);}lcont.sort(function(a,b){if(a<b)return-1;if(a>b)return 1;return 0;});var rcont=[];for(var j=0;j<=lcont.length-1;j++){var item=lcont[j];rcont.push(ctstyle(item));item.score>=300?tofile[['hiscore'+j]]=item:tofile[['rhyme'+j]]=item;}rcont.sort();themes.label(theme,'right',task,rcont.join(', '));if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, reset usage limits.\n'+config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour.'):console.log(config.rbrain.date.remain+'/'+config.rbrain.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.rbrain.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var chalk=require('chalk');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='define <word>';exports.aliases=['def'];exports.desc='Wordnik definitions';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},defdict:{alias:'d',desc:"CSV list of dictionaries or 'all'",default:'all',type:'string'},part:{alias:'p',desc:'CSV list of parts of speech. See http://developer.wordnik.com/docs.html for list of parts.',default:'',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{define:{canon:argv.c,limit:argv.l,defdict:argv.d,part:argv.p}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='definitions';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.define.canon+'&');pcont.push('sourceDictionaries='+config.wordnik.define.defdict+'&');pcont.push('includeRelated=false&');pcont.push('includeTags=false&');pcont.push('limit='+config.wordnik.define.limit+'&');pcont.push('partOfSpeech='+config.wordnik.define.part+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'definition',source:'http://www.wordnik.com'};var cstyle=_.get(chalk,theme.connector.style);var ctstyle=_.get(chalk,theme.content.style);var uline=_.get(chalk,theme.content.style+'.underline');var conn=cstyle(theme.connector.str);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];var icont=[];icont.push(ctstyle(item.text+' '));icont.push(uline(item.partOfSpeech));icont.push(conn);icont.push(ctstyle(item.sourceDictionary));themes.label(theme,'right','Definition',icont.join(''));tofile[['text'+i]]=item.text;tofile[['deftype'+i]]=item.partOfSpeech;tofile[['source'+i]]=item.sourceDictionary;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var chalk=require('chalk');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='define <word>';exports.aliases=['def'];exports.desc='Wordnik definitions';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},defdict:{alias:'d',desc:"CSV list of dictionaries or 'all'",default:'all',type:'string'},part:{alias:'p',desc:'CSV list of parts of speech. See http://developer.wordnik.com/docs.html for list of parts.',default:'',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{define:{canon:argv.c,limit:argv.l,defdict:argv.d,part:argv.p}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='definitions';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.define.canon+'&');pcont.push('sourceDictionaries='+config.wordnik.define.defdict+'&');pcont.push('includeRelated=false&');pcont.push('includeTags=false&');pcont.push('limit='+config.wordnik.define.limit+'&');pcont.push('partOfSpeech='+config.wordnik.define.part+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'definition',source:'http://www.wordnik.com'};var cstyle=_.get(chalk,theme.connector.style);var ctstyle=_.get(chalk,theme.content.style);var uline=_.get(chalk,theme.content.style+'.underline');var conn=cstyle(theme.connector.str);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];var icont=[];icont.push(ctstyle(item.text+' '));icont.push(uline(item.partOfSpeech));icont.push(conn);icont.push(ctstyle(item.sourceDictionary));themes.label(theme,'right','Definition',icont.join(''));tofile[['text'+i]]=item.text;tofile[['deftype'+i]]=item.partOfSpeech;tofile[['source'+i]]=item.sourceDictionary;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='example <word>';exports.aliases=['ex'];exports.desc='Wordnik examples';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},skip:{alias:'k',desc:'Number of results to skip',default:0,type:'number'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{example:{canon:argv.c,limit:argv.l,skip:argv.k}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='examples';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.example.canon+'&');pcont.push('includeDuplicates=false&');pcont.push('limit='+config.wordnik.example.limit+'&');!config.wordnik.example.skip?pcont.push('skip=0&'):pcont.push('skip='+config.wordnik.example.skip+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'example',source:'http://www.wordnik.com'};http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var body=JSON.parse(response.body);var list=body.examples;for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right','Example',item.text);tofile[['example'+i]]=item.text;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='example <word>';exports.aliases=['ex'];exports.desc='Wordnik examples';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},skip:{alias:'k',desc:'Number of results to skip',default:0,type:'number'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{example:{canon:argv.c,limit:argv.l,skip:argv.k}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='examples';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.example.canon+'&');pcont.push('includeDuplicates=false&');pcont.push('limit='+config.wordnik.example.limit+'&');!config.wordnik.example.skip?pcont.push('skip=0&'):pcont.push('skip='+config.wordnik.example.skip+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'example',source:'http://www.wordnik.com'};http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var body=JSON.parse(response.body);var list=body.examples;for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right','Example',item.text);tofile[['example'+i]]=item.text;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='hyphen <word>';exports.aliases=['hyphenate','hy'];exports.desc='Wordnik hyphenations';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},dict:{alias:'d',desc:'Source dictionary ahd, century, wiktionary, webster, wordnet',default:'all',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{hyphen:{canon:argv.c,dict:argv.d,limit:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='hyphenation';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.hyphen.canon+'&');if(argv.d!=='all')pcont.push('sourceDictionary='+config.wordnik.hyphen.dict+'&');pcont.push('limit='+config.wordnik.hyphen.limit+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'hyphenation',source:'http://www.wordnik.com'};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);var hcont=[];for(var i=0;i<=list.length-1;i++){var item=list[i];if(item.type==='stress'){hcont.push(''+chalk.red.bold(item.text));tofile[['stress'+i]]=item.text;}else if(item.type==='secondary stress'){hcont.push(ctstyle(item.text));tofile[['secondary'+i]]=item.text;}else{hcont.push(ctstyle(item.text));tofile[['syllable'+i]]=item.text;}if(i<list.length-1)hcont.push(ctstyle('-'));}themes.label(theme,'right','Hyphenation',hcont.join(''));if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='hyphen <word>';exports.aliases=['hyphenate','hy'];exports.desc='Wordnik hyphenations';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},dict:{alias:'d',desc:'Source dictionary ahd, century, wiktionary, webster, wordnet',default:'all',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{hyphen:{canon:argv.c,dict:argv.d,limit:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='hyphenation';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.hyphen.canon+'&');if(argv.d!=='all')pcont.push('sourceDictionary='+config.wordnik.hyphen.dict+'&');pcont.push('limit='+config.wordnik.hyphen.limit+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var tofile={type:'hyphenation',source:'http://www.wordnik.com'};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);var hcont=[];for(var i=0;i<=list.length-1;i++){var item=list[i];if(item.type==='stress'){hcont.push(''+chalk.red.bold(item.text));tofile[['stress'+i]]=item.text;}else if(item.type==='secondary stress'){hcont.push(ctstyle(item.text));tofile[['secondary'+i]]=item.text;}else{hcont.push(ctstyle(item.text));tofile[['syllable'+i]]=item.text;}if(i<list.length-1)hcont.push(ctstyle('-'));}themes.label(theme,'right','Hyphenation',hcont.join(''));if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var xml2js=require('xml2js');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='origin <word>';exports.aliases=['or','etymology'];exports.desc='Wordnik etymologies';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{origin:{canon:argv.c}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='etymologies';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.origin.canon+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var parser=new xml2js.Parser();var tofile={type:'etymology',source:'http://www.wordnik.com'};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var resp=JSON.parse(response.body);var origin=resp[0];parser.parseString(origin,function(err,result){if(!err){var root=result.ety;var content=root._;var ets=root.ets;ets=ets.join(', ');themes.label(theme,'right','Etymology',ctstyle(content+' '+ets));tofile.etymology=content;tofile.origin=ets;}else{throw new Error(err);}});if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var chalk=require('chalk');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var xml2js=require('xml2js');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='origin <word>';exports.aliases=['or','etymology'];exports.desc='Wordnik etymologies';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{origin:{canon:argv.c}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='etymologies';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.origin.canon+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);var parser=new xml2js.Parser();var tofile={type:'etymology',source:'http://www.wordnik.com'};var ctstyle=_.get(chalk,theme.content.style);http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var resp=JSON.parse(response.body);var origin=resp[0];parser.parseString(origin,function(err,result){if(!err){var root=result.ety;var content=root._;var ets=root.ets;ets=ets.join(', ');themes.label(theme,'right','Etymology',ctstyle(content+' '+ets));tofile.etymology=content;tofile.origin=ets;}else{throw new Error(err);}});if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='phrase <word>';exports.aliases=['ph','ngram'];exports.desc='Wordnik bi-gram phrases';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},weight:{alias:'w',desc:'Minimum weighted mutual info',default:13,type:'number'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{phrase:{canon:argv.c,limit:argv.l,weight:argv.w}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='phrases';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+argv.c+'&');pcont.push('limit='+argv.l+'&');pcont.push('wlmi='+argv.w+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down','Bi-gram phrases');var tofile={type:'phrase',source:'http://www.wordnik.com'};http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];console.log(item.gram1+' '+item.gram2);tofile[['agram'+i]]=item.gram1;tofile[['bgram'+i]]=item.gram2;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='phrase <word>';exports.aliases=['ph','ngram'];exports.desc='Wordnik bi-gram phrases';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},weight:{alias:'w',desc:'Minimum weighted mutual info',default:13,type:'number'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{phrase:{canon:argv.c,limit:argv.l,weight:argv.w}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='phrases';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+argv.c+'&');pcont.push('limit='+argv.l+'&');pcont.push('wlmi='+argv.w+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down','Bi-gram phrases');var tofile={type:'phrase',source:'http://www.wordnik.com'};http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];console.log(item.gram1+' '+item.gram2);tofile[['agram'+i]]=item.gram1;tofile[['bgram'+i]]=item.gram2;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='pronounce <word>';exports.aliases=['pr'];exports.desc='Wordnik pronunciations';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},dict:{alias:'d',desc:'Dictionary: ahd, century, cmu, macmillan, wiktionary, webster, wordnet',default:'',type:'string'},type:{alias:'t',desc:'Type: ahd, arpabet, gcide-diacritical, ipa',default:'',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{pronounce:{canon:argv.c,dict:argv.d,type:argv.t,limit:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='pronunciations';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.pronounce.canon+'&');if(config.wordnik.pronounce.dict!=='')pcont.push('sourceDictionary='+config.wordnik.pronounce.dict+'&');if(config.wordnik.pronounce.type!=='')pcont.push('typeFormat='+config.wordnik.pronounce.type+'&');pcont.push('limit='+config.wordnik.pronounce.limit+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down','Pronunciations');var tofile={type:'pronunciation',source:'http://www.wordnik.com'};tofile.word=word;http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right',word,item.raw+' - Type - '+item.rawType);tofile[['pronunciation'+i]]=item.raw;tofile[['type'+i]]=item.rawType;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='pronounce <word>';exports.aliases=['pr'];exports.desc='Wordnik pronunciations';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit number of results',default:5,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},dict:{alias:'d',desc:'Dictionary: ahd, century, cmu, macmillan, wiktionary, webster, wordnet',default:'',type:'string'},type:{alias:'t',desc:'Type: ahd, arpabet, gcide-diacritical, ipa',default:'',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{pronounce:{canon:argv.c,dict:argv.d,type:argv.t,limit:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='pronunciations';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.pronounce.canon+'&');if(config.wordnik.pronounce.dict!=='')pcont.push('sourceDictionary='+config.wordnik.pronounce.dict+'&');if(config.wordnik.pronounce.type!=='')pcont.push('typeFormat='+config.wordnik.pronounce.type+'&');pcont.push('limit='+config.wordnik.pronounce.limit+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down','Pronunciations');var tofile={type:'pronunciation',source:'http://www.wordnik.com'};tofile.word=word;http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right',word,item.raw+' - Type - '+item.rawType);tofile[['pronunciation'+i]]=item.raw;tofile[['type'+i]]=item.rawType;}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -1,1 +0,1 @@

'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='relate <word>';exports.aliases=['related','rel'];exports.desc='Wordnik related words';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit results = require(type option',default:10,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},type:{alias:'t',desc:'Relationship types to limit',default:'',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){(function(){var userConfig={wordnik:{relate:{canon:argv.c,type:argv.t,limit:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='relatedWords';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.relate.canon+'&');if(config.wordnik.relate.type!=='')pcont.push('relationshipTypes='+config.wordnik.relate.type+'&');pcont.push('limitPerRelationshipType='+config.wordnik.relate.limit+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down','Related words');var tofile={type:'related words',source:'http://www.wordnik.com'};tofile.word=word;http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right',item.relationshipType,''+item.words.join(', '));tofile[['type'+i]]=item.relationshipType;tofile[['words'+i]]=item.words.join(', ');}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});})();}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};
'use strict';/* eslint max-len:0 */var themes=require('../../themes');var tools=require('../../tools');var _=require('lodash');var df=require('date-fns');var http=require('good-guy-http')();var noon=require('noon');var CFILE=process.env.HOME+'/.leximaven.noon';exports.command='relate <word>';exports.aliases=['related','rel'];exports.desc='Wordnik related words';exports.builder={out:{alias:'o',desc:'Write cson, json, noon, plist, yaml, xml',default:'',type:'string'},force:{alias:'f',desc:'Force overwriting outfile',default:false,type:'boolean'},save:{alias:'s',desc:'Save flags to config file',default:false,type:'boolean'},limit:{alias:'l',desc:'Limit results = require(type option',default:10,type:'number'},canon:{alias:'c',desc:'Use canonical',default:false,type:'boolean'},type:{alias:'t',desc:'Relationship types to limit',default:'',type:'string'}};exports.handler=function(argv){if(process.env.WORDNIK===undefined)throw new Error('Put an API key in environment variable WORDNIK per documentation.');tools.checkConfig(CFILE);var config=noon.load(CFILE);var proceed=false;var reset=false;var stamp=new Date(config.wordnik.date.stamp);var minutes=df.differenceInMinutes(new Date(),stamp);var checkStamp=tools.limitWordnik(config);config=checkStamp[0];proceed=checkStamp[1];reset=checkStamp[2];if(proceed){var userConfig={wordnik:{relate:{canon:argv.c,type:argv.t,limit:argv.l}}};if(config.merge)config=_.merge({},config,userConfig);if(argv.s&&config.merge)noon.save(CFILE,config);if(argv.s&&!config.merge)throw new Error("Can't save user config, set option merge to true.");var theme=themes.loadTheme(config.theme);if(config.verbose)themes.label(theme,'down','Wordnik');var word=argv.word;var task='relatedWords';var prefix='http://api.wordnik.com:80/v4/word.json/';var apikey=process.env.WORDNIK;var uri=''+prefix+word+'/'+task+'?';var pcont=[];pcont.push('useCanonical='+config.wordnik.relate.canon+'&');if(config.wordnik.relate.type!=='')pcont.push('relationshipTypes='+config.wordnik.relate.type+'&');pcont.push('limitPerRelationshipType='+config.wordnik.relate.limit+'&');pcont.push('api_key='+apikey);var rest=pcont.join('');var url=''+uri+rest;url=encodeURI(url);themes.label(theme,'down','Related words');var tofile={type:'related words',source:'http://www.wordnik.com'};tofile.word=word;http({url:url},function(error,response){if(!error&&response.statusCode===200){if(response.headers['x-gg-state']==='cached'){config.wordnik.date.remain++;noon.save(CFILE,config);if(config.usage)console.log('Cached response, not decrementing usage.');}var list=JSON.parse(response.body);for(var i=0;i<=list.length-1;i++){var item=list[i];themes.label(theme,'right',item.relationshipType,''+item.words.join(', '));tofile[['type'+i]]=item.relationshipType;tofile[['words'+i]]=item.words.join(', ');}if(argv.o)tools.outFile(argv.o,argv.f,tofile);if(config.usage)reset?console.log('Timestamp expired, not decrementing usage.\n'+config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour.'):console.log(config.wordnik.date.remain+'/'+config.wordnik.date.limit+' requests remaining this hour, will reset in '+(59-minutes)+' minutes.');}else throw new Error('HTTP '+error.statusCode+': '+error.reponse.body);});}else throw new Error('Reached this hour\'s usage limit of '+config.wordnik.date.limit+'.');};

@@ -5,2 +5,17 @@ # Change Log

<a name="3.0.0"></a>
# [3.0.0](https://github.com/drawnepicenter/leximaven/compare/v2.3.4...v3.0.0) (2017-08-30)
### Features
* **project:** BREAKING_CHANGES:remove tests ([0113744](https://github.com/drawnepicenter/leximaven/commit/0113744))
### BREAKING CHANGES
* **project:** remove tests
<a name="2.3.4"></a>

@@ -7,0 +22,0 @@ ## [2.3.4](https://github.com/drawnepicenter/leximaven/compare/v2.3.3...v2.3.4) (2017-02-05)

{
"name": "leximaven",
"version": "2.3.4",
"version": "3.0.0",
"description": "A command line tool for searching word-related APIs.",

@@ -19,60 +19,38 @@ "author": "Andrew Prentice",

"bump": "git push origin master --tags && npm publish",
"clean": "rimraf bin coverage .nyc_output test/output",
"climate": "codeclimate-test-reporter < lcov.info",
"instrument": "cross-env BABEL_ENV=test babel src -d bin",
"lint": "standard --fix src",
"pretest": "cross-env BABEL_ENV=test babel test/test.es6 -o test/test.js",
"release": "standard-version",
"report": "nyc report -r text-lcov > lcov.info && nyc report -r html",
"reset": "npm run clean && npm run bin",
"test": "cross-env NODE_ENV=test nyc _mocha test/test.js",
"test": "echo 'No tests.'",
"watch": "babel -w src -d bin"
},
"nyc": {
"cache": true,
"include": [
"src/**/*"
],
"require": [
"babel-register"
],
"sourceMap": false,
"instrument": false
},
"dependencies": {
"chalk": "^1.1.3",
"date-fns": "^1.27.2",
"dot-prop": "^4.1.0",
"fs-extra": "^2.0.0",
"glob": "^7.1.1",
"good-guy-http": "^1.7.3",
"chalk": "^2.1.0",
"date-fns": "^1.28.5",
"dot-prop": "^4.2.0",
"fs-extra": "^4.0.1",
"glob": "^7.1.2",
"good-guy-http": "^1.10.0",
"lodash": "^4.17.4",
"noon": "^1.0.13",
"ora": "^1.1.0",
"noon": "^1.1.0",
"ora": "^1.3.0",
"random-word": "^2.0.0",
"term-size": "^0.1.0",
"wrap-ansi": "^2.1.0",
"x-ray": "^2.3.1",
"xml2js": "^0.4.17",
"term-size": "^1.2.0",
"wrap-ansi": "^3.0.1",
"x-ray": "^2.3.2",
"xml2js": "^0.4.19",
"yargonaut": "^1.1.2",
"yargs": "git+https://github.com/yargs/yargs.git"
"yargs": "^8.0.2"
},
"devDependencies": {
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-plugin-istanbul": "^3.1.2",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-lodash": "^3.2.11",
"babel-preset-latest": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^3.5.0",
"codeclimate-test-reporter": "^0.4.0",
"cross-env": "^3.1.4",
"cz-conventional-changelog": "^1.2.0",
"has-ansi": "^2.0.0",
"mocha": "^3.2.0",
"nyc": "^10.1.2",
"rimraf": "^2.5.4",
"sinon": "^1.17.7",
"standard": "^8.6.0",
"standard-version": "^4.0.0"
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"cross-env": "^5.0.5",
"cz-conventional-changelog": "^2.0.0",
"has-ansi": "^3.0.0",
"rimraf": "^2.6.1",
"standard": "^10.0.3",
"standard-version": "^4.2.0"
},

@@ -79,0 +57,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc