Skip to content

Commit

Permalink
wtf.js added to bin because npm install wtf_fetch is complaining abou…
Browse files Browse the repository at this point in the history
…t missing wtf.js in bin/
  • Loading branch information
Engelbert Niehaus committed Apr 10, 2019
1 parent cb2259b commit 2da3753
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions bin/wtf.js
@@ -0,0 +1,35 @@
#!/usr/bin/env node
var wtf = require('../src/index');
var args = process.argv.slice(2, process.argv.length);

var modes = {
'--json': 'json',
'--plaintext': 'plaintext',
'--html': 'html',
'--markdown': 'markdown',
'--latex': 'latex',
};
var mode = 'json';
args = args.filter((arg) => {
if (modes.hasOwnProperty(arg) === true) {
mode = modes[arg];
return false;
}
return true;
});

var title = args.join(' ');
if (!title) {
throw new Error('Usage: wtf_wikipedia Toronto Blue Jays --plaintext');
}

wtf.fetch(title, 'en', function (err, doc) {
if (err) {
console.error(err);
}
if (mode === 'json') {
console.log(JSON.stringify(doc[mode](), null, 0));
} else {
console.log(doc[mode]());
}
});
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "wtf_fetch",
"description": "Fetch Wiki markdown from MediaWiki",
"version": "1.0.5",
"version": "1.1.0",
"author": "Based on Work of Spencer Kelly <spencermountain@gmail.com> ",
"repository": {
"type": "git",
Expand Down

0 comments on commit 2da3753

Please sign in to comment.