Skip to content

Phase 2d: Port project init and sketch detection to Rust - #33

Merged
zackees merged 1 commit into
mainfrom
rust/phase-2d-project-init
Apr 12, 2026
Merged

zackees merged 1 commit into
mainfrom
rust/phase-2d-project-init

Conversation

@zackees

@zackees zackees commented Apr 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds crates/fastled-cli/src/project.rs porting the core logic from src/fastled/project_init.py and src/fastled/sketch.py to Rust
  • Interactive prompts remain in Python as specified; only pure-logic building blocks are ported
  • Adds fuzzy sketch-name matching via strsim (Jaro-Winkler distance), replacing the Python rapidfuzz-based approach for Rust callers
  • Exposes a project_available() PyO3 stub in fastled-py so Python can detect the capability at runtime

New public API (project.rs)

  • find_sketches(root: &Path) -> Vec<PathBuf> — finds directories with .ino/.cpp/platformio.ini, recurses into examples/ up to 3 levels deep
  • is_fastled_repo(path: &Path) -> bool — detects a FastLED repo via library.properties, src/FastLED.h, or library.json
  • is_sketch_dir(dir: &Path) -> bool — returns true when a directory contains at least one qualifying file
  • init_example(example_name: &str, dest: &Path, branch: Option<&str>) -> Result<PathBuf> — downloads a FastLED example from GitHub and copies it to dest
  • best_sketch_match(query: &str, candidates: &[&str]) -> Vec<String> — substring fast-path then Jaro-Winkler fuzzy fallback

Test plan

  • ./_cargo build --workspace — compiles clean
  • ./_cargo test --workspace — 34 Rust tests pass (14 new in project.rs)
  • ./_cargo clippy --workspace --all-targets -- -D warnings — clean
  • ./_cargo fmt --all --check — clean
  • bash lint — passes
  • bash test — 121 Python tests pass

Closes #21

- Add `crates/fastled-cli/src/project.rs` with `find_sketches`,
  `is_fastled_repo`, `is_sketch_dir`, `init_example`, and
  `best_sketch_match` (Jaro-Winkler fuzzy matching via strsim)
- Wire `mod project` into `main.rs`
- Expose `project_available()` PyO3 stub in `fastled-py`
- Add `strsim = "0.11"` to workspace dependencies
- Move `tempfile` from dev-dependencies to regular dependencies in
  fastled-cli (needed by `init_example` at runtime)
- 14 new Rust tests covering sketch detection, FastLED repo detection,
  and fuzzy name matching; all 34 workspace tests pass

Closes #21
@zackees
zackees merged commit ca1f876 into main Apr 12, 2026
1 of 9 checks passed
@zackees
zackees deleted the rust/phase-2d-project-init branch November 5, 2026 05:51
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.

Phase 2d: Port project init and sketch detection to Rust

1 participant