-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (37 loc) · 1.15 KB
/
Copy pathapp.js
File metadata and controls
44 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const yargs=require('yargs'),
geocode=require('./geocode/geocode'),
weather=require('./weather/weather');
const argv=yargs
.option({
a:{
demand:true,
alias:'address',
describe:'Address to fetch weather for',
string:true
}
})
.help()
.alias('help','h')
.argv;
// geocode.getLocation(argv.address,(errorMessage, results)=>{
// if(errorMessage){
// console.log(errorMessage);
// }else{
// console.log(results.address);
// weather.getWeather(results.latitude,results.longtitude,(errorMessage, weatherResult)=>{
// if(errorMessage){
// console.log(errorMessage);
// }else{
// console.log(`It's currently ${weatherResult.temperature}. It feels like ${weatherResult.apparentTemperature}.`);
// }
// });
// }
// });
geocode.getLocation(argv.address).then((location)=>{
console.log(JSON.stringify(location,undefined,2));
return weather.getWeather(location.latitude,location.longtitude);
}).then((res)=>{
console.log(JSON.stringify(res,undefined,2));
}).catch((errorMessage)=>{
console.log(errorMessage);
})