From c1304a765bcd2f02a0ec0166713935a09e6a09b0 Mon Sep 17 00:00:00 2001 From: Andrej Rasevic <andrej@rasevicengineering.com> Date: Fri, 11 Jan 2019 13:21:27 -0500 Subject: [PATCH] adding to code_along example --- cmsc388b/code_along/weather/cmds/help.js | 8 ++++---- cmsc388b/code_along/weather/index.js | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cmsc388b/code_along/weather/cmds/help.js b/cmsc388b/code_along/weather/cmds/help.js index 5ab2f4e..b300681 100644 --- a/cmsc388b/code_along/weather/cmds/help.js +++ b/cmsc388b/code_along/weather/cmds/help.js @@ -13,9 +13,9 @@ const menus = { } module.exports = (args) => { - const subCmd = args._[0] === 'help' - ? args._[1] - : args._[0] - + console.log("***********") + console.log(args._[0]) + const subCmd = args._[0] === 'help' ? args._[1] : args._[0] + console.log(subCmd) console.log(menus[subCmd] || menus.main) } \ No newline at end of file diff --git a/cmsc388b/code_along/weather/index.js b/cmsc388b/code_along/weather/index.js index 40ba40a..eca2508 100644 --- a/cmsc388b/code_along/weather/index.js +++ b/cmsc388b/code_along/weather/index.js @@ -2,8 +2,18 @@ const minimist = require('minimist') module.exports = () => { const args = minimist(process.argv.slice(2)) - //console.log(args); - const cmd = args._[0] + console.log("args is: "); + console.log(args); + let cmd = args._[0] || 'help' + + if (args.version || args.v) { + cmd = 'version' + } + + if (args.help || args.h) { + cmd = 'help' + } + console.log("------------") console.log(cmd); switch (cmd) { case 'today': -- GitLab