From 25471052be0a6212ab406b70a4badf0210f1884b Mon Sep 17 00:00:00 2001 From: Sarah Drasner Date: Sat, 3 Jul 2021 14:53:31 -0600 Subject: [PATCH] make it able to clear entries --- bin/clearLookup.js | 2 +- bin/lookup.js | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/clearLookup.js b/bin/clearLookup.js index d16bab0..0388897 100755 --- a/bin/clearLookup.js +++ b/bin/clearLookup.js @@ -20,5 +20,5 @@ inquirer.prompt(clearQuestion).then((answer) => { store.clear() } - console.log(chalk.cyan('jsexplorer ' + figures.arrowRight) + ' entries all cleared!') + console.log(chalk.cyan('\njsexplorer ' + figures.arrowRight) + ' entries all cleared!\n') }) \ No newline at end of file diff --git a/bin/lookup.js b/bin/lookup.js index 1c603ee..b54eeb1 100755 --- a/bin/lookup.js +++ b/bin/lookup.js @@ -1,8 +1,10 @@ #!/usr/bin/env node 'use strict' -import { store } from './store.js' +import chalk from 'chalk' import minimist from 'minimist' + +import { store } from './store.js' import { logFinalAnswer } from './logFinalAnswer.js' // gather the name as argument parameters and turn it into a string @@ -11,4 +13,14 @@ const argv = minimist(args); let finalArgv = argv._.join(" ") // look up the answer in the store -logFinalAnswer(store.get(finalArgv)) +if (store.get(finalArgv)) { + logFinalAnswer(store.get(finalArgv)) +} else { + console.log(chalk.redBright(`\nSorry!`) + ` +We can't quite find what you're looking for. +Perhaps run ${chalk.cyanBright('jsexplorer')} again and make sure you've stored it appropriately? + +You can also look up commands by typing ${chalk.cyanBright('man explorer')}\n`) +} + +