38 lines
914 B
JavaScript
38 lines
914 B
JavaScript
|
const yargs = require('yargs');
|
||
|
const request = require('request');
|
||
|
|
||
|
const geocode = require('./geocode/geocode.js');
|
||
|
const weather = require('./weather/weather.js');
|
||
|
|
||
|
const argv = yargs
|
||
|
.options({
|
||
|
a: {
|
||
|
demand: true,
|
||
|
alias: 'address',
|
||
|
describe: "Address to fetch weather for.",
|
||
|
string: true
|
||
|
}
|
||
|
})
|
||
|
.help()
|
||
|
.alias('help', 'h')
|
||
|
.argv;
|
||
|
|
||
|
geocode.geocodeAddress(argv.address, (errorMessage, results) => {
|
||
|
if (errorMessage){
|
||
|
console.log(errorMessage);
|
||
|
} else {
|
||
|
console.log(results.address);
|
||
|
weather.getWeather(results.latitude, results.longitude, (errorMessage, weatherResults) => {
|
||
|
if (errorMessage){
|
||
|
console.log(errorMessage)
|
||
|
} else {
|
||
|
console.log(`It's currently: ${weatherResults.temperature}. It feels like ${weatherResults.apparentTemperature}`);
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
console.log("Powered By https://darksky.net/poweredby/");
|