Skip to content
Snippets Groups Projects
Commit 4ba92bcf authored by Andrej Rasevic's avatar Andrej Rasevic
Browse files

first iteration of weather app

parent 4ed98517
No related branches found
No related tags found
No related merge requests found
# only relevant for Mac systems
.DS_STORE
#ingore npm packages
node_modules
#!/usr/bin/env node
// require('../')()
var index = require('../index')
index()
//console.log("Another way to run a node application");
\ No newline at end of file
console.log("executing the foo command");
\ No newline at end of file
const menus = {
main: `
weather [command] <options>
today .............. show weather for today
version ............ show package version
help ............... show help menu for a command`,
today: `
weather today <options>
--location, -l ..... the location to use`,
}
module.exports = (args) => {
const subCmd = args._[0] === 'help'
? args._[1]
: args._[0]
console.log(menus[subCmd] || menus.main)
}
\ No newline at end of file
module.exports = (args) => {
console.log('today is sunny')
}
const { version } = require('../package.json')
module.exports = (args) => {
console.log(`v${version}`)
}
const minimist = require('minimist')
module.exports = () => {
const args = minimist(process.argv.slice(2))
//console.log(args);
const cmd = args._[0]
console.log(cmd);
switch (cmd) {
case 'today':
require('./cmds/today')(args)
break
case 'foo':
require('./cmds/foo')
break
case 'version':
require('./cmds/version')(args)
break
case 'help':
require('./cmds/help')(args)
break
default:
console.error(`"${cmd}" is not a valid command!`)
break
}
}
{
"name": "weather",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
}
}
}
{
"name": "weather",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"bin": {
"weather": "bin/weather"
},
"dependencies": {
"minimist": "^1.2.0"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment