import { ensureConfigDirs } from "../../utils/config.js";
import { listProjects } from "../../db/repositories/projects.js";
/**
 * Handle the `pocketcoder projects` CLI command.
 * Lists all registered projects in a formatted table.
 */
export async function projectsCommand() {
    try {
        await ensureConfigDirs();
        const projects = listProjects();
        if (projects.length === 0) {
            console.log("No projects registered");
            return;
        }
        // Print header
        console.log(`${"ID".padEnd(38)}${"NAME".padEnd(20)}${"PATH".padEnd(40)}STATUS`);
        for (const project of projects) {
            const status = "idle";
            console.log(`${project.project_id.padEnd(38)}${project.name.padEnd(20)}${project.path.padEnd(40)}${status}`);
        }
    }
    catch (err) {
        const message = err instanceof Error ? err.message : String(err);
        console.error(`Failed to list projects: ${message}`);
        process.exitCode = 1;
    }
}
//# sourceMappingURL=projects.js.map