Branch
Ubuntu (APT Install)
sudo apt install branch
README
Branch
Branch is a smart, modern CLI tool for scanning directories and exporting structured data.
Features
- 🌳 Tree view (default)
- 👁️ Optional content preview mode (head/tail/full)
- 📄 CSV export
- 🗄️ SQLite export
- ⚡ Fast and structured output
🚀 Quick Start
cargo run -- .
Or (after building):
target/release/branch <PATH>
By default, this runs in Tree mode.
🌳 Default Behavior (Tree Mode)
If you run Branch with no preview flags, it prints tree-only:
branch .
👁️ Content Preview Mode (head / tail / full)
Preview mode is enabled automatically when you use any of these flags:
--head N→ show first N lines of each text file--tail N→ show last N lines of each text file--full→ show full text file contents
✅ You do not have to specify --format text for these to work.
Examples:
branch . --head 20
branch . --tail 20
branch . --full
Notes on file reading (--max-bytes)
- Default: 2,000,000 bytes per file
- Larger files are truncated
- Binary files are skipped
📦 Output Formats
Tree (default)
branch .
Text (tree + contents)
branch . --format text --head 20
branch . --format text --tail 20
branch . --format text --full
CSV
branch . --format csv --out files.csv
SQLite
branch . --format sqlite --db data.db
⚙️ Options
| Option | Description |
|---|---|
| PATH | Root path to scan |
| --all | Include hidden files |
| --depth N | Limit traversal |
| --head N | Show first N lines |
| --tail N | Show last N lines |
| --full | Show full content |
| --format | tree / text / csv / sqlite |
| --out FILE | Write output file |
| --db FILE | SQLite database |
| --max-bytes N | Max bytes per file |
📄 Man Page
man -l docs/branch.1
✅ Status
- Core engine complete
- CLI working
- Multi-format supported
License
MIT