-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add api features to console logs for extra results information #23
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ const chalk = require('chalk'); | |
const program = require('commander'); | ||
const request = require('request'); | ||
|
||
const consoleWidth = () => { | ||
return parseInt(process.stdout.columns) | ||
} | ||
|
||
program | ||
.version('0.2.0') | ||
.arguments('<phrase>') | ||
|
@@ -24,6 +28,9 @@ program | |
if (err) throw new Error(err); | ||
var trimRes; | ||
var results = JSON.parse(body).list; | ||
|
||
console.log('='.repeat(consoleWidth())); | ||
|
||
if (results.length === 0) { | ||
console.log(chalk.red('No results were found, please try another phrase')); | ||
} else { | ||
|
@@ -34,7 +41,11 @@ program | |
} | ||
trimRes.forEach((result) => { | ||
if (typeof (result.definition) !== undefined) { | ||
console.log(chalk.bold.cyan('=======================\n') + result.definition); | ||
console.log('Word: ' + chalk.magenta(result.word)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Magenta doesn't work on my powershell @jwu910 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
console.log('Definition: ' + chalk.magenta(result.definition)); | ||
console.log('Score: ' + (result.thumbs_up - result.thumbs_down)); | ||
console.log(chalk.bold.green('Ayys: ') + result.thumbs_up + ' | ' + chalk.bold.red('Nayys: ') + result.thumbs_down); | ||
console.log('='.repeat(consoleWidth())); | ||
} | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We removed cyan from our split, was this on purpose?