Skip to content

Directory support for amber build#1090

Open
siba-dev wants to merge 13 commits intoamber-lang:stagingfrom
siba-dev:staging
Open

Directory support for amber build#1090
siba-dev wants to merge 13 commits intoamber-lang:stagingfrom
siba-dev:staging

Conversation

@siba-dev
Copy link
Copy Markdown

@siba-dev siba-dev commented Apr 22, 2026

Added directory support for amber build like described in #1070.

Summary by CodeRabbit

  • New Features

    • Build accepts directory inputs, discovers source files recursively, preserves relative paths when writing outputs, validates output paths for directory builds, and supports stdin input.
  • Refactor

    • File-discovery logic consolidated into a shared utilities module and exposed for reuse.
  • Tests

    • Added integration tests for directory builds, output placement, invalid-output errors, and stdin handling; unit tests cover recursive discovery, symlink traversal, and loop detection.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56f2c369-673a-4f41-bed7-354481c9a096

📥 Commits

Reviewing files that changed from the base of the PR and between c84aa68 and e603a75.

📒 Files selected for processing (1)
  • src/tests/io.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/io.rs

📝 Walkthrough

Walkthrough

Build handling was extracted to handle_build, which resolves the effective target, detects stdin vs single-file vs directory input, uses utils::io::find_amber_files for recursive .ab discovery when input is a directory, validates/creates output directories, and compiles/writes per-file .sh outputs preserving relative paths.

Changes

Cohort / File(s) Summary
Core Build Refactoring
src/main.rs
Extracted build flow into handle_build; distinguishes stdin, single-file, and directory inputs; for directories, enumerates .ab files and compiles each to a corresponding .sh, creating parent dirs as needed.
File Discovery Utility
src/utils/io.rs, src/utils/mod.rs
Added pub fn find_amber_files(dir: &PathBuf, files: &mut Vec<PathBuf>) -> std::io::Result<()> implemented with walkdir; exported new pub mod io;.
Tests: CLI & IO
src/tests/cli.rs, src/tests/io.rs, src/tests/io/find_amber_files/...
Added integration tests for amber build (directory input, custom output dir, invalid output, missing input, stdin) and unit tests for recursive discovery, symlink resolution, and loop detection; added fixture files for symlink/loop cases.
Test Imports / API Uses
src/testing.rs, src/tests/testing.rs
Removed local find_amber_files implementation and updated imports to use crate::utils::io::find_amber_files.
Manifest
Cargo.toml
Added walkdir dependency to support recursive traversal.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Handler
    participant Build as Build Logic
    participant Discover as File Discovery
    participant Compile as Compiler
    participant FS as File System

    CLI->>Build: handle_build(input, output, target)

    alt input is directory
        Build->>FS: stat/check input directory
        Build->>Discover: find_amber_files(dir)
        Discover->>FS: WalkDir traversal (follow symlinks)
        Discover-->>Build: list of .ab files

        loop each .ab file
            Build->>FS: compute relative .sh path
            Build->>FS: create parent directories if missing
            Build->>Compile: compile Amber file -> script
            Compile-->>Build: compiled script content
            Build->>FS: write .sh file
        end
    else single file or stdin
        Build->>Compile: compile single input (or stdin)
        Compile-->>Build: compiled script content
        Build->>FS: write to output path or stdout
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Tirito6626

Poem

🐰 I hop through folders, sniff each trail,
I find the amber files without fail;
I stitch their paths and make new homes,
Compile their scripts and write to domes —
Hop hop hooray, the build prevails!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title "Directory support for amber build" clearly and specifically summarizes the main change: adding directory support to the amber build command, which is the central focus of this changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@Mte90
Copy link
Copy Markdown
Member

Mte90 commented Apr 28, 2026

So just to understand compiles every *.ab file to a dedicated *.sh?

I like the idea and also the new io.rs file (maybe in the future we can move more stuff there and organize better).

Can you address the Coderabbit's review?

@Mte90 Mte90 requested review from KrosFire and Tirito6626 April 28, 2026 09:09
@siba-dev
Copy link
Copy Markdown
Author

@Mte90, yes you understood correctly, glad you like it.
Ill work on the Code Rabbit issues later today.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as duplicate.

@Mte90
Copy link
Copy Markdown
Member

Mte90 commented Apr 29, 2026

@coderabbitai resume

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

✅ Actions performed

Reviews resumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants