const SUBJECT_TEMPLATE = `
// _schedule_
Schedule::factory()->create([
    'subject' => '_schedule_' ,
    'day' => _day_,
    'startTime' => '_startTime_',
    'endTime' => '_endTime_',
    'description'=>'_description_'
]);
`.trim();

const fs = require('fs');

const schedule_list_raw = fs.readFileSync('./schedule_list.txt', { encoding: 'utf-8' }).trim();
const schedule_list = schedule_list_raw.split('\n').map(r => r.split(': '));

const schedule_list_out = schedule_list.map(s =>
    SUBJECT_TEMPLATE.replace(/_schedule_/g, s[0])
        .replace(/_startTime_/g, s[1])
        .replace(/_endTime_/g, s[2])
        .replace(/_description_/g, s[3])
        .replace(/_day_/g, 14)
        .replace(/\w' \w/g, "\\' "),
);

fs.writeFileSync('./write_schedule.out', schedule_list_out.join('\n\n'), { encoding: 'utf-8' });
