UNPKG

markdown-code

Version:

Keep code examples in Markdown synchronized with actual source files

38 lines (36 loc) 981 B
import { extractSnippets } from "./chunk-IHXCU4UX.js"; import "./chunk-3RW5RA4J.js"; import { getValidatedConfig, handleError, logWarningsAndErrors } from "./chunk-WJFWHUDV.js"; // src/commands/extract.ts var command = "extract"; var describe = "Extract code blocks from markdown to snippet files"; function logExtractionResults(result) { if (result.extracted.length > 0) { console.log(`Extracted ${result.snippetsCreated} snippets from:`); result.extracted.forEach((file) => console.log(` ${file}`)); } else { console.log("No code blocks found to extract."); } } var handler = async (argv) => { try { const config = await getValidatedConfig(argv); console.log("Extracting snippets from code blocks..."); const result = await extractSnippets(config); logWarningsAndErrors(result.warnings, result.errors); logExtractionResults(result); } catch (error) { handleError(error); } }; export { command, describe, handler };