Refactor src/lib.mjs to use VALID_CADENCES constant

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-14 14:15:55 +00:00
1 parent 695adb6dc9
commit c94ff84da8
1 file changed
+5 -5
+5 -5
View File
@@ -48,7 +48,7 @@ export async function cmdCheck(cadence) {
const namespace = getNamespace();
const dateStr = todayDateStr();
const config = loadTorchConfig();
const pausedAgents = (cadence === 'daily' ? config.scheduler.paused.daily : config.scheduler.paused.weekly) || [];
const pausedAgents = config.scheduler.paused[cadence] || [];
console.error(`Checking locks: namespace=${namespace}, cadence=${cadence}, date=${dateStr}`);
console.error(`Relays: ${relays.join(', ')}`);
@@ -199,7 +199,7 @@ export async function cmdList(cadence) {
const relays = getRelays();
const namespace = getNamespace();
const dateStr = todayDateStr();
const cadences = cadence ? [cadence] : ['daily', 'weekly'];
const cadences = cadence ? [cadence] : [...VALID_CADENCES];
console.error(`Listing active locks: namespace=${namespace}, cadences=${cadences.join(', ')}`);
@@ -325,7 +325,7 @@ export async function main(argv) {
switch (args.command) {
case 'check': {
if (!args.cadence || !VALID_CADENCES.has(args.cadence)) {
console.error('ERROR: --cadence <daily|weekly> is required for check');
console.error(`ERROR: --cadence <${[...VALID_CADENCES].join('|')}> is required for check`);
throw new ExitError(1, 'Missing cadence');
}
await cmdCheck(args.cadence);
@@ -338,7 +338,7 @@ export async function main(argv) {
throw new ExitError(1, 'Missing agent');
}
if (!args.cadence || !VALID_CADENCES.has(args.cadence)) {
console.error('ERROR: --cadence <daily|weekly> is required for lock');
console.error(`ERROR: --cadence <${[...VALID_CADENCES].join('|')}> is required for lock`);
throw new ExitError(1, 'Missing cadence');
}
await cmdLock(args.agent, args.cadence, args.dryRun);
@@ -347,7 +347,7 @@ export async function main(argv) {
case 'list': {
if (args.cadence && !VALID_CADENCES.has(args.cadence)) {
console.error('ERROR: --cadence must be daily or weekly');
console.error(`ERROR: --cadence must be one of: ${[...VALID_CADENCES].join(', ')}`);
throw new ExitError(1, 'Invalid cadence');
}
await cmdList(args.cadence || null);