Git Product home page Git Product logo

rhack's Introduction

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.

rhack's People

Contributors

alexander-jackson avatar asaaki avatar bradfier avatar nakabonne avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.