cargo-rhack

Crates.iocargo-rhack
lib.rscargo-rhack
version0.1.5
sourcesrc
created_at2023-05-19 23:59:30.299474
updated_at2024-03-19 06:19:39.13989
descriptionTemporarily edit your Cargo dependencies
homepagehttps://github.com/simonsan/cargo-rhack
repositoryhttps://github.com/simonsan/cargo-rhack
max_upload_size
id869150
size100,325
(simonsan)

documentation

README

cargo-rhack

Version info

Description

You want to quickly put a sneaky macro kind of like dbg! into external crates to find out how some internal data structure works? If so cargo-rhack is for you!

cargo-rhack makes it easier to edit external crates code that your project depends on.

Usage

Let's say you want to modify the reqwest crate.

[dependencies]
reqwest = "0.11"

Run the following:

cargo rhack edit reqwest

This will make a copy of the crate into $HOME/.rhack/reqwest-0.11.1 and add its path to the [patch] section in your Cargo.toml whose path is automatically detected:

[patch.crates-io]
reqwest = { path = "/home/you/.rhack/reqwest-0.11.1" }

Now your package uses the locally checked out copy instead of one from crates.io. You can now open the files (typically by leveraging the "Jump to Definition" feature) and then feel free to modify the source code.

Undoing

Simply run the undo command then you can undo all of the changes to your Cargo.toml:

cargo rhack undo

Keep in mind that this command doesn't remove any copy of crates.

Settings

It uses $HOME/.rhack as the destination to copy the source code of the external crates by default. You can change it by setting and exposing the $RHACK_DIR environment variable.

Installation

For MacOS, Linux, and Windows, prebuilt binaries are available through here.

Cargo

cargo install cargo-rhack

Binstall

cargo binstall cargo-rhack

Contributing

Found a bug? Open an issue!

Got an idea for an improvement? Don't keep it to yourself!

Code of Conduct

Please review and abide by the general Rust Community Code of Conduct when contributing to this project. In the future, we might create our own Code of Conduct and supplement it at this location.

Minimum Rust version policy

This crate's minimum supported rustc version is 1.74.1.

The current policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if crate 1.0 requires Rust 1.20.0, then crate 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, crate 1.y for y > 0 may require a newer minimum version of Rust.

In general, this crate will be conservative with respect to the minimum supported version of Rust.

Acknowledgements

The original author of this tool is nakabonne, I revived it and fixed some things. I'm grateful for the original author's efforts and contributions to the Rust community. I hope this tool will be useful for many people in the Rust community going forward.

Original inspiration

This tool is highly inspired by gohack. It clearly stimulated an incentive to creation. A big "thank you!" goes out to them.

License

BSD-3-Clause license; see LICENSE.

Commit count: 82

cargo fmt