From 555a7c09955c8a29791e63a307741c43eddf7bfd Mon Sep 17 00:00:00 2001 From: Joe Danziger Date: Mon, 26 May 2025 20:30:47 -0400 Subject: [PATCH] add aggregate reporting for rules add command --- scripts/modules/commands.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/modules/commands.js b/scripts/modules/commands.js index a1d5979b..43ecba9d 100644 --- a/scripts/modules/commands.js +++ b/scripts/modules/commands.js @@ -2740,6 +2740,7 @@ Examples: } const removalResults = []; + const addResults = []; for (const profile of expandedProfiles) { if (!isValidProfile(profile)) { @@ -2762,6 +2763,14 @@ Examples: console.log( chalk.blue(`Completed adding rules for profile: ${profile}`) ); + + // Store result with profile name for summary + addResults.push({ + profileName: profile, + success: addResult.success, + failed: addResult.failed + }); + console.log( chalk.green( `Summary for ${profile}: ${addResult.success} rules added, ${addResult.failed} failed.` @@ -2780,6 +2789,28 @@ Examples: } } + // Print summary for additions + if (action === RULES_ACTIONS.ADD && addResults.length > 0) { + const totalSuccess = addResults.reduce((sum, r) => sum + r.success, 0); + const totalFailed = addResults.reduce((sum, r) => sum + r.failed, 0); + const successfulProfiles = addResults + .filter((r) => r.success > 0) + .map((r) => r.profileName); + + if (successfulProfiles.length > 0) { + console.log( + chalk.green( + `\nSuccessfully added rules for: ${successfulProfiles.join(', ')}` + ) + ); + console.log( + chalk.green( + `Total: ${totalSuccess} rules added, ${totalFailed} failed.` + ) + ); + } + } + // Print summary for removals if (action === RULES_ACTIONS.REMOVE) { const successes = removalResults