Crates.io | rustmerge |
lib.rs | rustmerge |
version | 0.1.7 |
source | src |
created_at | 2024-10-14 07:38:41.585235 |
updated_at | 2024-11-19 08:54:21.454996 |
description | A Cargo subcommand that merges all Rust source files in a package into a single file. |
homepage | |
repository | https://github.com/b3hr4d/rustmerge |
max_upload_size | |
id | 1408039 |
size | 51,212 |
rustmerge
is a Cargo subcommand that merges all Rust source files in a package or workspace into single files. It works with both workspace projects and single-package projects.
Its primary use case is to simplify the process of sharing Rust projects with AI tools, e.g., for training machine learning models or code analysis. By merging all source files into a single file per package, you can easily share the project with tools that require a single file as input.
.rs
files in a package into a single filecfg
attributes on modulesYou can install rustmerge
using Cargo:
cargo install rustmerge
cargo rustmerge
cargo rustmerge <package_name>
cargo rustmerge --all
cargo rustmerge [<package_name>] --output <path>
If there's only one package in the workspace and you're not using --all
, you can omit the package name.
By default, the merged Rust file(s) will be created in the target
directory of your current working directory, named rustmerge/<package_name>.rs
.
Merge a single-package project:
cd my-rust-project
cargo rustmerge
Merge a specific package in a workspace:
cd my-rust-workspace
cargo rustmerge my-package
Merge all packages in a workspace:
cd my-rust-workspace
cargo rustmerge --all
Merge with a custom output path:
cargo rustmerge --output /path/to/output/merged_project.rs
Merge all packages with a custom output directory:
cargo rustmerge --all --output /path/to/output/dir
The tool will print information about the merged files, including their locations and sizes. For example:
Merged and formatted Rust program for package 'my-package' created in "/path/to/project/target/rustmerge/my-package.rs"
File size: 12345 bytes
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.