UNPKG

finview

Version:

A command-line tool for monitoring financial data and market trends in real-time directly from your terminal.

56 lines (51 loc) 1.4 kB
const inquirer = require('inquirer').default || require('inquirer'); async function interactiveMenu() { const questions = [ { type: 'list', name: 'command', message: 'Select a command:', choices: ['hello', 'chart', 'quote', 'financials', 'ratios', 'news'] }, { type: 'input', name: 'ticker', message: 'Enter ticker (if applicable):', when: (answers) => ['quote', 'financials', 'ratios', 'news'].includes(answers.command) } ]; const answers = await inquirer.prompt(questions); switch (answers.command) { case 'hello': { const chalk = require('chalk').default || require('chalk'); console.log(chalk.green('Welcome to !')); break; } case 'chart': { const { showChart } = require('./chart'); showChart(); break; } case 'quote': { const { getQuote } = require('./quote'); await getQuote(answers.ticker); break; } case 'financials': { const { getFinancials } = require('./financials'); await getFinancials(answers.ticker); break; } case 'ratios': { const { getRatios } = require('./ratios'); await getRatios(answers.ticker); break; } case 'news': { const { getNews } = require('./news'); await getNews(answers.ticker); break; } } } module.exports = { interactiveMenu };