-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
74 lines (49 loc) · 1.97 KB
/
app.js
File metadata and controls
74 lines (49 loc) · 1.97 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require('dotenv').config();
const { listarLugares, inquirerMenu, pausa, leerInput } = require("./helpers/inquirer");
const Busqueda = require("./models/busqueda");
require("colors");
const main = async () => {
const busqueda = new Busqueda();
busqueda.loadHistorial();
let opt=0;
do{
opt = await inquirerMenu();
switch (opt) {
case 1:
//data input for search
const lugar=await leerInput('Ciudad: ');
//searching places and selecting one of them
const lugares=await busqueda.ciudad(lugar);
const lugarSeleccionado = await listarLugares(lugares);
if(lugarSeleccionado){
//searching info about a specific place
const [ciudad]=lugares.filter( lugar => lugar.id===lugarSeleccionado);
busqueda.agregarHistorial(ciudad.nombre);
//filling info
const {temp, min, max, desc}=await busqueda.getInfo(ciudad.lat, ciudad.lon);
console.clear();
console.log('\nInformacion de la ciudad\n'.green);
console.log('Ciudad: '+ciudad.nombre.yellow);
console.log(`\tLat: ${ciudad.lat}`);
console.log(`\tLon: ${ciudad.lon}`);
console.log('Temperatura: '+temp);
console.log('\tMinima: '+min);
console.log('\tMaxima: '+max);
console.log('\Descripcion: '+desc.yellow);
}
break;
case 2:
busqueda.historial.forEach( (l, i) => {
const idx= `${i+1}.`.green;
console.log(`${idx} ${l}`);
});
break;
case 3:
busqueda.limpiarHistorial();
break;
};
if(opt)await pausa();
}while (opt)
console.clear();
}
main();