cargo-hilly

Crates.iocargo-hilly
lib.rscargo-hilly
version0.1.1
created_at2025-07-01 16:32:45.812498+00
updated_at2025-08-10 12:03:57.887597+00
descriptionUtility for Rust projects that helps migrate flat module files (e.g., "foo.rs") into the more idiomatic Rust module layout.
homepage
repository
max_upload_size
id1733389
size15,587
Jérémie Drouet (jdrouet)

documentation

README

cargo-hilly 🏔️

cargo-hilly is a utility for Rust projects that helps migrate flat module files (e.g., "foo.rs") into the more idiomatic Rust module layout using subdirectories with mod.rs (e.g., "foo/mod.rs"). It scans your workspace for Rust crates and identifies modules that can be moved to this structure, then performs the migration for you.

Why?

I don't like the new way of organizing the modules. It's hard to go through a complex project when you need to go in the parent directory to find a file related to the current module.

Features

  • Recursively finds all Rust crates in the current directory.
  • Detects .rs files that have a sibling directory (e.g., "foo.rs" and "foo/").
  • Moves eligible files to the corresponding mod.rs location (e.g., src/foo.rs ’ src/foo/mod.rs).
  • Supports dry-run and check modes for safe migrations.

Usage

Run the tool from the root of your workspace:

cargo install cargo-hilly

By default, it will migrate all eligible modules and print the actions taken.

Options

  • --dry-run: Shows what would be migrated without making any changes. Useful for previewing the migration.

    cargo hilly --dry-run
    
  • --check: Checks if there are modules that need to be migrated. Exits with a non-zero status if migration is needed, but does not make any changes. Implies dry-run.

    cargo hilly --check
    

Example

Suppose you have:

src/
  foo.rs
  foo/
    bar.rs

After running cargo-hilly, if src/foo/mod.rs does not exist, foo.rs will be moved to foo/mod.rs.

License

MIT

Commit count: 0

cargo fmt