import { readFileSync, existsSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const docsDir = join(__dirname, "..", "docs");
export function docsCommand(path) {
    const docPath = resolveDocPath(path);
    if (!docPath) {
        console.error(`Documentation not found: ${path || "index"}\n\nRun 'specific docs' to see available topics.`);
        process.exit(1);
    }
    const content = readFileSync(docPath, "utf-8");
    console.log(content);
}
function resolveDocPath(path) {
    if (!path) {
        const indexPath = join(docsDir, "index.md");
        return existsSync(indexPath) ? indexPath : null;
    }
    // Try path.md first
    const directPath = join(docsDir, `${path}.md`);
    if (existsSync(directPath)) {
        return directPath;
    }
    // Try path/index.md for directories
    const indexPath = join(docsDir, path, "index.md");
    if (existsSync(indexPath)) {
        return indexPath;
    }
    return null;
}
//# sourceMappingURL=docs.js.map