-
Notifications
You must be signed in to change notification settings - Fork 0
/
printSchedule.js
52 lines (44 loc) · 1.21 KB
/
printSchedule.js
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
const inquirer = require("inquirer");
const Scheduler = require("./Scheduler");
const parseMovies = require("./parseMovies");
const path = require("path");
async function promptForDay() {
const answers = await inquirer.prompt([
{
type: "list",
name: "day",
message: "Choose a day to see the movie schedule:",
choices: [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
],
},
]);
return answers.day;
}
function makePromptedSchedule(inputFile, day) {
const movies = parseMovies(inputFile);
const scheduler = new Scheduler();
scheduler.setMovies(movies);
scheduler.makeDailySchedule(day);
scheduler.printSchedule();
}
async function main() {
let inputFile;
if (process.argv.length >= 3) {
inputFile = process.argv[2];
console.log(`Grabbing movie data from: ${inputFile}`);
} else {
inputFile = path.join(__dirname, "input.txt");
console.log(`No file path provided. CURRENT FILE is: ${inputFile}`);
}
const day = await promptForDay();
console.log(`The theater's schedule for: ${day}`);
makePromptedSchedule(inputFile, day);
}
main().catch((err) => console.error(err));