• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Rust
  • License
    BSD 3-Clause "New...
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Temporary edit external crates that your project depends on

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.

More Repositories

1

ali

Generate HTTP load and plot the results in real-time
Go
3,557
star
2

tstorage

An embedded time-series database
Go
988
star
3

pbgopy

Copy and paste between devices
Go
789
star
4

gosivy

Real-time visualization tool for Go process metrics
Go
459
star
5

golintui

A simple terminal UI for Go linters
Go
79
star
6

cleanarchitecture-sample

Sample REST API demonstrating the clean architecture
Go
44
star
7

nestif

Detect deeply nested if statements in Go source code
Go
37
star
8

sxds

simple-xds that provides configuration and route table to data-plane for service discovery
Go
14
star
9

giturl

A scheme converter for Git URLs
Go
8
star
10

WebCrawlerForSerps

Web crawler that scrapes Google search results
Go
6
star
11

AR_Voice

Mobile game to beat enemies by voice
C#
3
star
12

netsurfer

netsurfer is a very lightweight scraping framework
Go
2
star
13

StaticCollector

Application to analyze static files of competing sites
JavaScript
2
star
14

unusedparam

Lint go source files and detect unused function parameters. All you need is files, no need to make preparations anything such as code generation.
Go
2
star
15

isucon8-final

Go
1
star
16

tstorage-bench

Benchmark tests for Tstorage project
Go
1
star
17

RiajuMusou

้žใƒชใ‚ขใŒใ‚ฏใƒชใ‚นใƒžใ‚นใฎๅคœใซใƒชใ‚ขๅ……ใ‚’ใชใŽๅ€’ใ—ใฆใ„ใ็ˆฝๅฟซใ‚ขใ‚ฏใ‚ทใƒงใƒณ
C#
1
star
18

dotfiles-ansible

Shell
1
star
19

site

โ˜• My personal site
HTML
1
star
20

leetcode-helpers

Go
1
star
21

nomad-sdk-playground

Go
1
star
22

roster

A cli tool to add values to google spreadsheets
Go
1
star
23

parrot

A cli tool to display received parameters
Go
1
star