Skip to content
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

Merged
merged 3 commits into from
Feb 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>')
Expand All @@ -24,6 +28,9 @@ program
if (err) throw new Error(err);
var trimRes;
var results = JSON.parse(body).list;

console.log('='.repeat(consoleWidth()));
Copy link
Contributor

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?


if (results.length === 0) {
console.log(chalk.red('No results were found, please try another phrase'));
} else {
Expand All @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magenta doesn't work on my powershell @jwu910

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI highlighting does not help
image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screenshot from 2018-01-21 22-43-27

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()));
}
});
}
Expand Down