Files
clawdbot/src/commands/sandbox-formatters.ts
sheeek 7f02b62bba style(sandbox): fix linting errors
- Remove unused normalizeOptions function
- Fix line length violations (format long lines)
- Fix import order (alphabetical)
- Format function signatures for readability

All lint checks now passing.
2026-01-09 13:23:16 +01:00

54 lines
1.3 KiB
TypeScript

/**
* Formatting utilities for sandbox CLI output
*/
export function formatStatus(running: boolean): string {
return running ? "🟢 running" : "⚫ stopped";
}
export function formatSimpleStatus(running: boolean): string {
return running ? "running" : "stopped";
}
export function formatImageMatch(matches: boolean): string {
return matches ? "✓" : "⚠️ mismatch";
}
export function formatAge(ms: number): string {
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
if (days > 0) return `${days}d ${hours % 24}h`;
if (hours > 0) return `${hours}h ${minutes % 60}m`;
if (minutes > 0) return `${minutes}m`;
return `${seconds}s`;
}
/**
* Type guard and counter utilities
*/
export type ContainerItem = {
running: boolean;
imageMatch: boolean;
containerName: string;
sessionKey: string;
image: string;
createdAtMs: number;
lastUsedAtMs: number;
};
export function countRunning<T extends { running: boolean }>(
items: T[],
): number {
return items.filter((item) => item.running).length;
}
export function countMismatches<T extends { imageMatch: boolean }>(
items: T[],
): number {
return items.filter((item) => !item.imageMatch).length;
}