-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (40 loc) · 1.62 KB
/
app.js
File metadata and controls
46 lines (40 loc) · 1.62 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
42
43
44
const { inquireMenu, pausa, leerInput, listarLugares } = require('./helpers/inquirier');
const Busquedas = require('./models/busquedas');
require('colors');
const main = async () => {
let opt;
const busqueda = new Busquedas();
do {
opt = await inquireMenu();
switch (opt) {
case 1:
const termino = await leerInput('Ciudad: ');
const lugares = await busqueda.ciudad(termino);
const id = await listarLugares(lugares);
if (id === 0) continue;
const lugarSel = await lugares.find(l => l.id === id);
busqueda.agregarHistorial(lugarSel.nombre);
const clima = await busqueda.clima(lugarSel.lat, lugarSel.lng);
console.log('\nInformación de la ciudad\n'.green);
console.log('Ciudad:', lugarSel.nombre);
console.log('Latitud:', lugarSel.lat);
console.log('Longitud:', lugarSel.lng);
console.log('Temperatura:', clima.temp);
console.log('Mínima:', clima.max);
console.log('Máxima:', clima.min);
console.log('Cómo está el clima:', clima.description);
console.log();
break;
case 2:
console.log();
busqueda.historial.forEach((lugar, i) => {
const idx = `${i + 1}`.green;
console.log(`${idx}. ${lugar}`);
})
console.log();
break;
}
if (opt !== 0) await pausa();
} while (opt !== 0);
}
main();