'use strict';

const ask = require('./lib/ask');
const SearchEngine = require('.');

(async () => {

    console.log(`Loading engine...`);

    var engine = new SearchEngine();
    await engine.load();

    console.log(`Engine loaded...`);

    while (true) {
        let input = await ask('Enter description:');

        let results = await engine.search(input, 5);

        for (let i=0; i<results.length; i++) {
            let r = results[i];
            console.log(`${i+1} ${r.chapter}`)
        }
    }
    
    process.exit();

})();