-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·50 lines (36 loc) · 942 Bytes
/
main.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
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
import { select } from "@inquirer/prompts";
import chalk from "chalk";
import { getCoinPrice, spinner } from "./getCoinprice.js";
import executeBanner from "./executeBanner.js";
import asciichart from 'asciichart';
const main = async () => {
await executeBanner()
const answer = await select({
message: "Select your Coin",
choices: [
{
name: "BTC",
value: "bitcoin",
description: "Bitcoin price",
},
{
name: "ETH",
value: "ethereum",
description: "Ethereum price",
},
],
});
const prices = await getCoinPrice(answer);
const chart = asciichart.plot(prices, {
height: 20,
colors: [asciichart.green],
});
if (prices !== null) {
spinner.success({
text: `${answer.toUpperCase()} current price is: ${chalk.green.bold(`$${prices[prices.length - 1]}`)}`,
});
}
console.log(chart);
};
main();