-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wtf_fetch demo included in /docs folder
- Loading branch information
Engelbert Niehaus
committed
Nov 5, 2018
1 parent
c757e60
commit cb2259b
Showing
8 changed files
with
1,058 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env node | ||
var wtf_fetch = require('../src/index'); | ||
var args = process.argv.slice(2, process.argv.length); | ||
|
||
var modes = { | ||
'--wikipedia': 'wikipedia', | ||
'--wikiversity': 'wikiversity', | ||
'--wikivoyage': 'wikivoyage' | ||
}; | ||
var mode = 'wikipedia'; | ||
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_fetch Toronto Blue Jays --wikipedia'); | ||
} | ||
|
||
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]()); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.