feat: add status exit code gate

This commit is contained in:
Affaan Mustafa
2026-05-11 12:27:06 -04:00
committed by Affaan Mustafa
parent b1e67788f7
commit 9887ba6123
4 changed files with 40 additions and 2 deletions

View File

@@ -113,6 +113,7 @@ Examples:
ecc repair --dry-run
ecc auto-update --dry-run
ecc status --json
ecc status --exit-code
ecc status --markdown --write status.md
ecc sessions
ecc sessions session-active --json

View File

@@ -8,10 +8,12 @@ const { createStateStore } = require('./lib/state-store');
function showHelp(exitCode = 0) {
console.log(`
Usage: node scripts/status.js [--db <path>] [--json|--markdown] [--write <path>] [--limit <n>]
Usage: node scripts/status.js [--db <path>] [--json|--markdown] [--write <path>] [--limit <n>] [--exit-code]
Query the ECC SQLite state store for active sessions, recent skill runs,
install health, pending governance events, and linked work items.
Use --exit-code to return 2 when readiness needs attention.
`);
process.exit(exitCode);
}
@@ -23,6 +25,7 @@ function parseArgs(argv) {
json: false,
markdown: false,
writePath: null,
exitCode: false,
help: false,
limit: 5,
};
@@ -37,6 +40,8 @@ function parseArgs(argv) {
parsed.json = true;
} else if (arg === '--markdown') {
parsed.markdown = true;
} else if (arg === '--exit-code') {
parsed.exitCode = true;
} else if (arg === '--write') {
parsed.writePath = args[index + 1] || null;
index += 1;
@@ -364,6 +369,10 @@ async function main() {
}
printHuman(payload);
}
if (options.exitCode && payload.readiness.status !== 'ok') {
process.exitCode = 2;
}
} catch (error) {
console.error(`Error: ${error.message}`);
process.exit(1);