Baker follows a layered flow that starts with command parsing and ends with generating files on disk. Each layer owns a focused responsibility so contributors can reason about changes without touching unrelated subsystems.
- CLI (
src/cli) –main.rsdelegates tocli::runner::run. The runner validates command-line arguments, prepares output directories, and orchestrates the remaining steps. - Template Acquisition (
src/loader) –get_templateresolves a local path or Git repository into a working template directory. - Configuration (
src/config) –Config::load_configparsesbaker.yaml/baker.json, returning a validatedConfigV1. Configuration controls template suffixes, loop separators, hooks, and user questions. - Q&A (
src/prompt) –prompt::handler::PromptHandlerdrives interactive collection of answers usingdialoguer, honoring defaults, validation rules, and--non-interactivemode. - Template Engine (
src/renderer) –MiniJinjaRendererrenders file content, filenames, and hook names using the collected answers. - Processing (
src/template) –TemplateProcessorevaluates each template entry, decides whether to write, copy, create directories, or ignore paths (respecting.bakerignore), and expands loop-driven templates into multiple outputs. - Filesystem Effects (
src/cli/processor.rs) –FileProcessorappliesTemplateOperations, prompting for overwrites unless suppressed by--skip-confirms. Hooks run before and after processing when provided.
src/constants.rscentralises exit codes, verbosity thresholds, and validation defaults.src/error.rsdefines recoverable and fatal error types with contextual messages.src/exthosts helper traits (for example,PathExt) to keep core modules uncluttered.
- Answers collected from prompts feed back into renderers, enabling templated defaults and conditional paths.
- Dry-run mode short-circuits filesystem writes while still exercising rendering and logging for safe previews.
- Skip-confirm flags toggle confirmation prompts independently for overwriting files and executing hooks.
Understanding these boundaries helps isolate changes: adjust prompting logic inside prompt, extend template behaviour in template, and keep the runner focused on sequencing the pipeline.