replies.js
1 #!/usr/bin/env node 2 3 /** 4 * Replies Stage CLI 5 */ 6 7 import '../utils/load-env.js'; 8 import { runRepliesStage, getRepliesStats, processOptOuts } from '../stages/replies.js'; 9 import { parseFlags } from '../utils/flag-parser.js'; 10 import Logger from '../utils/logger.js'; 11 12 const logger = new Logger('RepliesCLI'); 13 14 async function main() { 15 const command = process.argv[2]; 16 17 try { 18 if (command === 'stats') { 19 const stats = getRepliesStats(); 20 console.log('\nReplies Statistics:'); 21 console.log(`Total Replies: ${stats.total_replies}`); 22 console.log(`Processed: ${stats.processed}`); 23 console.log(`Positive: ${stats.positive}`); 24 console.log(`Neutral: ${stats.neutral}`); 25 console.log(`Negative: ${stats.negative}`); 26 console.log('\nBy Intent:'); 27 for (const [intent, count] of Object.entries(stats.byIntent)) { 28 console.log(` ${intent}: ${count}`); 29 } 30 } else if (command === 'opt-outs') { 31 const count = processOptOuts(); 32 console.log(`Processed ${count} opt-out requests`); 33 } else { 34 const { limit } = parseFlags(); 35 const showAll = process.argv.includes('--all'); 36 await runRepliesStage({ limit, showAll }); 37 } 38 } catch (err) { 39 logger.error(err.message); 40 process.exit(1); 41 } 42 } 43 44 main();