-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.js
46 lines (38 loc) · 1.08 KB
/
run.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
import readline from 'readline';
import { main } from './index.js';
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
async function askForUrl() {
return new Promise((resolve) => {
rl.question('Please enter a website URL (or type "exit" to quit): ', (url) => {
resolve(url.trim());
});
});
}
async function run() {
try {
while (true) {
const url = await askForUrl();
if (url.toLowerCase() === 'exit') {
console.log('Goodbye!');
break;
}
if (!url) {
console.log('Please enter a valid URL');
continue;
}
console.log(`\nProcessing ${url}...\n`);
const results = await main([url]);
console.log('\nResults:');
console.log(JSON.stringify(results, null, 2));
console.log('\n-------------------\n');
}
} catch (error) {
console.error('Error:', error.message);
} finally {
rl.close();
}
}
run();