-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathneedsCli.js
37 lines (33 loc) · 873 Bytes
/
needsCli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const dbird = require('./needs.js')
const _ = require('lodash')
const colors = require('colors')
function sortNeeds (needs) {
let str = ''
if (needs.photo) {
str = str + '📷'
}
if (needs.audio) {
str = str + '🎤'
}
if (needs.sighting) {
str = '🔭'
}
return str
}
async function go () {
const list = await dbird()
if (process.argv[2] === 'web') {
console.log(`## Washington County, Vermont Needs for 2020
`)
}
_.forEach(
_.sortBy(list, [(n) => n.rarity]).reverse(), (v, k) => {
if (process.argv[2] === 'web') {
console.log(`* ${v.rarity.toFixed(0) + '%'}\t${sortNeeds(v.needs)}\t**${v.common}** (_${v.scientific}_)`)
} else {
console.log(`${colors.yellow(v.rarity.toFixed(2) + '%')}\t${sortNeeds(v.needs)}\t${colors.blue(v.common)} - ${colors.italic(v.scientific)}`)
}
}
)
}
go()