2 releases
new 0.2.1 | Jan 15, 2025 |
---|---|
0.2.0 | Jan 14, 2025 |
#155 in Cargo plugins
224 downloads per month
27KB
434 lines
Cargo Onefile
Cargo Onefile is a Rust tool that generates a single file containing all the source code of a Rust project, primarily designed for piping source code into Large Language Models (LLMs).
Table of Contents
Installation
To install Cargo Onefile, you need to have Rust and Cargo installed on your system. If you don't have them installed, follow the instructions on the official Rust website.
Once Rust is installed, you can install Cargo Onefile using the following command:
cargo install cargo-onefile
Usage
To use Cargo Onefile, navigate to your Rust project directory and run:
cargo onefile
This will generate a single file containing all the source code of your project. By default, the output file will be named onefile.rs
in the current directory.
For more options, you can use the --help
flag:
cargo onefile --help
Features
- Single File Generation: Combines all source files into a single file for easy sharing or analysis.
- Flexible Output: Supports writing to a file or stdout, with customizable output paths.
- Dependency Inclusion: Option to include project dependencies in the output.
- Customizable Filtering: Allows filtering files based on size, modification date, and file extensions.
- Performance Metrics: Includes an info mode to measure performance and provide statistics on the processed files.
Configuration
Cargo Onefile offers various configuration options:
--stdout
: Output to stdout instead of a file.--table-of-contents
: Include a table of contents at the top of the output.-o, --output <PATH>
: Specify the output file path.-p, --manifest-path <PATH>
: Specify the path to the Cargo.toml file.--head <PATH>
: Prepend contents of a header file to the output.--depth <DEPTH>
: Set the maximum depth to search for files.--skip-gitignore <BOOL>
: Choose whether to skip gitignored files.-d, --dependencies
: Include project dependencies in the output.--separator <STRING>
: Set the separator shown between files.--newer-than <DATETIME>
: Exclude files older than the specified datetime.--older-than <DATETIME>
: Exclude files newer than the specified datetime.--smaller-than <SIZE>
: Exclude files larger than the specified size in bytes.--larger-than <SIZE>
: Exclude files smaller than the specified size in bytes.--max-files <NUMBER>
: Set the maximum number of files to include.-E, --extension <EXTENSION>
: Include files with the specified extension(s).-e, --exclude <FILE>
: Exclude specified files from the output.
For a complete list of options, use the --help
flag.
Contributing
Contributions to Cargo Onefile are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Write your code and tests.
- Ensure all tests pass by running
cargo test
. - Submit a pull request with a clear description of your changes.
Please adhere to the existing code style and include appropriate tests for new features.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
For support, questions, or feedback, please open an issue on the GitHub repository.
Dependencies
~7–16MB
~200K SLoC