Skip to content

Commit 4090e6e

Browse files
committed
feat: add installation script and README for ritobin-tools
1 parent 28077c9 commit 4090e6e

File tree

2 files changed

+188
-0
lines changed

2 files changed

+188
-0
lines changed

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# ritobin-tools
2+
3+
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](LICENSE-MIT)
4+
5+
A fast, modern CLI utility for working with League of Legends `.bin` files (binary property trees). Convert between binary and human-readable text formats, and diff files with ease.
6+
7+
## Features
8+
9+
- **Convert** — Transform `.bin` files to readable `.py`/`.ritobin` text format and vice versa
10+
- **Diff** — Compare two bin files with colored unified diff output
11+
- **Batch Processing** — Recursively convert entire directories
12+
- **Hashtable Support** — Automatic hash resolution for readable property names
13+
- **Cross-Platform** — Works on Windows, Linux, and macOS
14+
15+
## Installation
16+
17+
### Windows (PowerShell)
18+
19+
Run this command in PowerShell to install the latest release:
20+
21+
```powershell
22+
irm https://raw.githubusercontent.com/LeagueToolkit/ritobin-tools/main/install.ps1 | iex
23+
```
24+
25+
This will:
26+
- Download the latest release
27+
- Install to `%LOCALAPPDATA%\LeagueToolkit\ritobin-tools`
28+
- Add to your PATH automatically
29+
30+
### From Source
31+
32+
Requires [Rust 1.85+](https://rustup.rs/) (edition 2024).
33+
34+
```bash
35+
git clone https://github.com/LeagueToolkit/ritobin-tools.git
36+
cd ritobin-tools
37+
cargo build --release
38+
```
39+
40+
The binary will be available at `target/release/ritobin-tools`.
41+
42+
## Usage
43+
44+
### Convert
45+
46+
Convert between binary `.bin` files and text `.py`/`.ritobin` formats.
47+
48+
```bash
49+
# Binary to text
50+
ritobin-tools convert input.bin
51+
# → Creates input.py
52+
53+
# Text to binary
54+
ritobin-tools convert input.py
55+
# → Creates input.bin
56+
57+
# Specify output path
58+
ritobin-tools convert input.bin -o output.py
59+
60+
# Convert all files in a directory
61+
ritobin-tools convert ./data/
62+
63+
# Recursively convert all files
64+
ritobin-tools convert ./data/ -r
65+
```
66+
67+
### Diff
68+
69+
Compare two bin files and display differences in unified diff format.
70+
71+
```bash
72+
# Basic diff
73+
ritobin-tools diff old.bin new.bin
74+
75+
# Adjust context lines (default: 3)
76+
ritobin-tools diff old.bin new.bin -C 5
77+
78+
# Disable colored output
79+
ritobin-tools diff old.bin new.bin --no-color
80+
```
81+
82+
Supports comparing any combination of `.bin`, `.py`, and `.ritobin` files.
83+
84+
## Configuration
85+
86+
A `config.toml` file is automatically created next to the executable on first run.
87+
88+
```toml
89+
hashtable_dir = "/path/to/LeagueToolkit/bin_hashtables"
90+
```
91+
92+
### Hashtables
93+
94+
Hashtables enable human-readable names for properties instead of raw hashes. By default, the tool looks for hashtables in:
95+
96+
```
97+
~/Documents/LeagueToolkit/bin_hashtables/
98+
```
99+
100+
You can override this with:
101+
- The `--hashtable-dir` CLI flag
102+
- The `hashtable_dir` setting in `config.toml`
103+
104+
## License
105+
106+
Licensed under either of:
107+
108+
- [MIT License](LICENSE-MIT)
109+
- [Apache License, Version 2.0](LICENSE-APACHE)

install.ps1

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Installs the latest ritobin-tools release for Windows (user scope)
2+
3+
param(
4+
[string]$Owner = "LeagueToolkit",
5+
[string]$Repo = "ritobin-tools",
6+
[string]$Channel = "windows-x64",
7+
[string]$InstallDir = "$env:LOCALAPPDATA\LeagueToolkit\ritobin-tools"
8+
)
9+
10+
$ErrorActionPreference = 'Stop'
11+
12+
Write-Host "Installing ritobin-tools..." -ForegroundColor Cyan
13+
14+
if (!(Test-Path -LiteralPath $InstallDir)) {
15+
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
16+
}
17+
18+
# Get latest release metadata
19+
$releaseApi = "https://api.github.com/repos/$Owner/$Repo/releases/latest"
20+
try {
21+
$release = Invoke-RestMethod -Uri $releaseApi -Headers @{ 'User-Agent' = 'ritobin-tools-installer' }
22+
} catch {
23+
throw "Failed to query GitHub releases: $($_.Exception.Message)"
24+
}
25+
26+
$tag = $release.tag_name
27+
# Extract the first semantic version (handles tags like "v0.1.1" or "ritobin-tools-v0.1.1")
28+
$match = [regex]::Match($tag, '\d+\.\d+\.\d+([\-\+][A-Za-z0-9\.-]+)?')
29+
$version = if ($match.Success) { $match.Value } else { $tag.TrimStart('v') }
30+
31+
$assetName = "ritobin-tools-$version-$Channel.zip"
32+
$asset = $release.assets | Where-Object { $_.name -eq $assetName } | Select-Object -First 1
33+
if (-not $asset) {
34+
# Fallback: find any ritobin-tools asset matching the channel
35+
$pattern = "^ritobin-tools-.*-" + [regex]::Escape($Channel) + "\.zip$"
36+
$asset = $release.assets | Where-Object { $_.name -match $pattern } | Select-Object -First 1
37+
}
38+
if (-not $asset) {
39+
throw "Could not find asset matching '$assetName' (channel $Channel) in the latest release."
40+
}
41+
if ($asset.name -ne $assetName) { $assetName = $asset.name }
42+
43+
$zipPath = Join-Path $env:TEMP $assetName
44+
Write-Host "Downloading $assetName ($version)..." -ForegroundColor Yellow
45+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $zipPath -UseBasicParsing
46+
47+
Write-Host "Extracting to $InstallDir" -ForegroundColor Yellow
48+
Expand-Archive -Path $zipPath -DestinationPath $InstallDir -Force
49+
50+
# Create a shim directory so PATH is simple and stable
51+
$binDir = Join-Path $InstallDir 'bin'
52+
if (!(Test-Path -LiteralPath $binDir)) { New-Item -ItemType Directory -Path $binDir | Out-Null }
53+
54+
# Ensure the executable exists
55+
$exePath = Join-Path $InstallDir 'ritobin-tools.exe'
56+
if (!(Test-Path -LiteralPath $exePath)) {
57+
throw "ritobin-tools.exe not found after extraction: $exePath"
58+
}
59+
60+
# Place a thin cmd shim in bin to avoid spaces in paths and simplify PATH updates
61+
$shimCmd = @"
62+
@echo off
63+
"$exePath" %*
64+
"@
65+
Set-Content -LiteralPath (Join-Path $binDir 'ritobin-tools.cmd') -Value $shimCmd -Encoding Ascii -Force
66+
67+
# Add to user PATH if missing
68+
$currentPath = [Environment]::GetEnvironmentVariable('Path', 'User')
69+
if (-not ($currentPath -split ';' | Where-Object { $_ -eq $binDir })) {
70+
$newPath = if ([string]::IsNullOrEmpty($currentPath)) { $binDir } else { "$currentPath;$binDir" }
71+
[Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
72+
Write-Host "Added to PATH (User): $binDir" -ForegroundColor Green
73+
} else {
74+
Write-Host "PATH already contains: $binDir" -ForegroundColor Green
75+
}
76+
77+
Write-Host "Installed ritobin-tools $version to $InstallDir" -ForegroundColor Green
78+
Write-Host "Open a new terminal and run: ritobin-tools --help" -ForegroundColor Cyan
79+

0 commit comments

Comments
 (0)