Temporary edit external crates that your project depends on

Overview

rhack

Version info

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 rhack is for you!

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:

$ 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:

$ 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.

Debian/Ubuntu

wget https://github.com/nakabonne/rhack/releases/download/v0.1.0/rhack_linux_amd64.deb
apt install ./rhack_linux_amd64.deb

Arch Linux

An AUR package is available.

yay rhack

Cargo

cargo install rhack

From source

git clone https://github.com/nakabonne/rhack.git
cargo build --release
sudo install -m755 target/release/rhack /usr/local/bin/rhack

If you want to generate the man page, you can install it with scdoc.

sudo mkdir -p /usr/local/share/man/man1
scdoc < rhack.1.scd > rhack.1
sudo install -m644 rhack.1 /usr/local/share/man/man1/rhack.1

Acknowledgements

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

Comments
  • Update to clap v3 (and other dependencies as well)

    Update to clap v3 (and other dependencies as well)

    Recently a lot of tools broke for me when I had to reinstall them via cargo install. Interestingly that install command doesn't respect the lock file per default.

    Nevertheless we want our dependencies up to date, esp when on beta branches and breaking changes. I hope clap doesn't break more before the final release.

    Here the changes were fairly simple.

    Additionally:

    • cargo update everything
    • fix issues for updates (mainly toml_edit changes)
    • apply cargo clippy recommendations

    Reference: https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#305---2022-01-05

    opened by asaaki 2
  • feat: use the workspace manifest root

    feat: use the workspace manifest root

    When using cargo locate-project, specify the --workspace option. This will provide a different result when within a workspace, providing the path to the top-level Cargo.toml file instead of the one for the workspace member. Patch changes to workspace member TOML files will not alter builds and will display a warning instead.

    For projects that do not use workspaces, the output of this command is identical to the previous version.

    opened by alexander-jackson 1
  • chore: enable colored help screen

    chore: enable colored help screen

    Probably personal preference, but I find it easier if commands have colored help as it is easier to distinguish the different sections of the help screen. People who do not want colors in CLIs almost always have NO_COLOR set anyway, so this won't affect those people, as clap follows the no color specification: https://no-color.org/

    opened by mainrs 1
  • Add a man page and mention AUR repo

    Add a man page and mention AUR repo

    I love the tool so I added some more docs and packaged it for Arch users at https://aur.archlinux.org/packages/rhack/

    rhack-man

    The file rhack.1.scd is in scdoc format, which is a more human readable format for these documents than TROFF.

    I also added a tiny Makefile so users don't have to figure out how to generate the man page themselves, and can install them together.

    The normal cargo build workflow is of course unchanged.

    This will need a small update to the release GitHub action, but I can't easily test it from this PR.

    opened by bradfier 0
  • Perhaps consider renaming it to cargo-hack?

    Perhaps consider renaming it to cargo-hack?

    Seeing as it deals with cargo more than rust and the usage of the term cargo is even encouraged for such things? This would hopefully let me just issue cargo hack and get done with things :). Small thing but I think it might matter

    opened by asdf8dfafjk 4
Owner
Ryo Nakao
Hej!
Ryo Nakao
A temporary repo for ETH connector to be used by EVM

ETH connector for Rainbow bridge Definitions bridgedETH - NEP-141 fungible-token representation of ETH inside Near. nETH - native ETH inside Near EVM.

Project Aurora 36 Jul 26, 2022
Demo: Connect Phala's Fat Contract to external storage services, both centralized (Amazon s3) and decentralized .

This demo shows how to connect Phala's Fat Contract to external storage services, both centralized (Amazon s3) and decentralized (Arweave/Filecoin thr

Christopher Fok 2 Aug 30, 2022
An intentionally-limited Rust implementation of the Docker runtime with no external dependencies.

lil-docker An lightweight Rust implementation of Docker's run command. lil docker is an accessible implementation of a very basic Docker runner (which

Miguel Piedrafita 38 Jan 9, 2023
Extends cargo to execute the given command on multiple crates - upstream is at

cargo-multi GitLab CI: master: develop: Travis: master: develop: Extends cargo to execute the given command on multiple crates. Inspired by git multi.

Cyril Plisko 6 Feb 27, 2022
Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transactions of your non-custodial wallets on a provider of your choice, all while respecting your privacy

Bitcoin Push Notification Service (BPNS) Description Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transacti

BPNS 1 May 2, 2022
A library to help you sew up your Ethereum project with Rust and just like develop in a common backend

SewUp Secondstate EWasm Utility Program, a library helps you sew up your Ethereum project with Rust and just like development in a common backend. The

Second State 48 Dec 18, 2022
A template for your next Rust project.

Opinionated Rust Template A template for your next Rust project. To start coding run: cargo generate tomkarw/opinionated-rust-template Only requires j

Tom Karwowski 8 Dec 1, 2022
deductive verification of Rust code. (semi) automatically prove your code satisfies your specifications!

Le marteau-pilon, forges et aciéries de Saint-Chamond, Joseph-Fortuné LAYRAUD, 1889 About Creusot is a tool for deductive verification of Rust code. I

Xavier Denis 609 Dec 28, 2022
Employ your built-in wetware pattern recognition and signal processing facilities to understand your network traffic

Nethoscope Employ your built-in wetware pattern recognition and signal processing facilities to understand your network traffic. Check video on how it

Vesa Vilhonen 86 Dec 5, 2022
Koofr Vault is an open-source, client-side encrypted folder for your Koofr cloud storage offering an extra layer of security for your most sensitive files.

Koofr Vault https://vault.koofr.net Koofr Vault is an open-source, client-side encrypted folder for your Koofr cloud storage offering an extra layer o

Koofr 12 Dec 30, 2022
A Rust port of the password primitives used in Django Project.

Rust DjangoHashers A Rust port of the password primitives used in Django Project. Django's django.contrib.auth.models.User class has a few methods to

Ronaldo Ferreira 52 Nov 17, 2022
Source project for the Internet Computer software

The Internet Computer is the world’s first blockchain that runs at web speed and can increase its capacity without bound. Like the Internet (which is composed of many machines adhering to TCP/IP protocol) and blockchain protocols (such as Bitcoin and Ethereum).

DFINITY 1.2k Jan 1, 2023
HyperCube is a free and open source blockchain project for everyone to use.

XPZ Public Chain HyperCube is a free and open source blockchain project for everyone to use. 日本語 简体中文 正體中文 HyperCube Wiki Wha is HyperCube HyperCube i

null 949 Dec 31, 2022
This is the Repo used to learn blockchain development in conjusction with the CyberGen NFT Project.

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

null 1 Nov 3, 2021
Terra Trophies is a copy of Ethereum's POAP project for Terra

Terra Trophies Terra Trophies is a copy of Ethereum's POAP project for Terra. It allows anyone to create digital badges for participants of events, or

larry.{ust,sol,thor} 18 Dec 7, 2022
Secret contract for Anons project.

Snip-721 Protocal by Baedrik template with several edits Minting Limits mint() caps tokens max at 580 mint() will keep count of how many anons each ad

Stake or Die 14 Jul 9, 2022
Battery-included Solana/Anchor project skeleton.

Anchor Skeleton Battery-included Solana/Anchor project skeleton. Features Rust test only: All tests (integration, unit) are written in Rust, so the co

Weiyuan Wu 5 Feb 23, 2022
A prototype project integrating jni rust into Kotlin and using protobuf to make them work together

KotlinRustProto a prototype project integrating jni rust into Kotlin and using protobuf to make them work together How to start add a RPC call in Droi

woo 11 Sep 5, 2022
A Rust port of the password primitives used in Django Project.

Rust DjangoHashers A Rust port of the password primitives used in Django Project. Django's django.contrib.auth.models.User class has a few methods to

Ronaldo Ferreira 52 Nov 17, 2022