Skip to main content

apply_init

Function apply_init 

Source
pub fn apply_init(
    target_dir: &Path,
    force: bool,
) -> Result<ApplyResult, ApplyError>
Expand description

Apply rust-bucket to a target directory for the first time.

This function implements the first-time flow as specified in ARCHITECTURE.md:

  1. Assert Cargo.toml exists (this is a Rust crate)
  2. Assert .git/ exists (git init was done)
  3. Check for conflicts using generator::check_conflicts()
    • If conflicts exist and !force, fail with list of conflicts
    • If conflicts exist and force, warn and continue
  4. Prompt for choices (test_timeout) using cli::prompt_test_timeout()
  5. Create Config with choices
  6. Write rust-bucket.toml using config.save()
  7. Extract templates to temp dir using templates::extract_to_temp()
  8. Render templates to target dir using generator::render()
  9. Run verification using verify::run_all()
  10. Return result

§Arguments

  • target_dir - The target directory to apply rust-bucket to
  • force - If true, overwrite existing managed files; if false, fail on conflicts

§Errors

Returns ApplyError if:

  • The target is not a Rust crate (no Cargo.toml)
  • The target is not a git repository (no .git/)
  • Conflicting files exist and force is false
  • Any step in the process fails (config save, template extraction, rendering, verification)