-
Notifications
You must be signed in to change notification settings - Fork 64
Add ability to sort advices based on cli arguments #223
Add ability to sort advices based on cli arguments #223
Conversation
12be68c
to
dbd5eae
Compare
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.
👍
Great stuff, just some tweaks.
lib/table.js
Outdated
@@ -3,6 +3,8 @@ | |||
var wrap = require('word-wrap'); | |||
|
|||
var Table = require('cli-table2'), | |||
argv = require('yargs').argv, |
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.
Put the definition of the sortBy option into cli.js (with documentation). I suggest a choice of 'name' and 'score', with a default of 'name'. Then make sortProperty an argument to getNewTable.
lib/table.js
Outdated
@@ -3,6 +3,8 @@ | |||
var wrap = require('word-wrap'); | |||
|
|||
var Table = require('cli-table2'), | |||
argv = require('yargs').argv, | |||
_ = require('lodash'), |
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.
'lodash' is not a dependency in package.json. Just depend on 'lodash.sortBy' (making sortProperty an argument you can skip _.isUndefined).
lib/table.js
Outdated
|
||
let sortedAdvice; | ||
|
||
sortedAdvice = sortProperties(adviceList, argv.sortBy); |
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.
while the changes above, you can simplify this to
sortedAdvice = sortBy(adviceList, sortProperty);
Added ability to sort advices based on cli arguments
20e683b
to
cc0eb53
Compare
@tobli done :D! |
Thanks! |
npm test
and test linting bynpm run lint
Description
Add the ability to sort advices list based on the cli argument (--sortBy=), if no argument is passed set name as default. This is the pull request for the feature #222