- Rust 99%
- HCL 1%
* fix: check file size before reading to prevent OOM The previous implementation read the entire file into memory before checking if it exceeded max_data_size. For very large files, this could cause out-of-memory errors before the size check could reject the file. This fix uses fs::metadata() to check the file size BEFORE reading its contents. This prevents OOM errors when users accidentally try to open multi-gigabyte files. For stdin input, the size check still happens after reading (since we can't know stdin size beforehand), but this is unavoidable. Changes: - Check file metadata.len() before fs::read() for file paths - Add integration test that verifies rejection of >30 MiB files - Improve error message to show both file size and limit The fix maintains backward compatibility - stdin behavior is unchanged, and the default 30 MiB limit remains the same. * fix: avoid u64-to-usize truncation in file size check Compare metadata.len() (u64) against max_data_size widened to u64 instead of narrowing the file size to usize, which would silently wrap on 32-bit targets and let oversized files through. |
||
|---|---|---|
| .github | ||
| assets | ||
| config | ||
| docs | ||
| examples | ||
| src | ||
| tests | ||
| .gitignore | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
| typos.toml | ||
OTree - Object Tree TUI Viewer
A command line tool to view objects (JSON/YAML/TOML/XML) in TUI tree widget.
Install
Download binary files from release page.
You can also build it from source (require cargo installed):
cargo install --git https://github.com/fioncat/otree
Arch Linux (AUR)
You can install otree from the AUR with using an AUR helper.
paru -S otree
macOS and Linux (Homebrew)
You can install otree using Homebrew.
brew install otree
Usage
Open a JSON/YAML/TOML file in TUI tree viewer:
otree /path/to/file.json
otree /path/to/file.yaml
otree /path/to/file.toml
otree /path/to/file.xml
For more command usage, please run otree --help.
You can configure TUI keys, colors, and more in ~/.config/otree.toml, the default configuration is here.
For all available actions and their default key bindings, please refer to: All Available Actions.
For how to configure TUI colors, please refer to: Colors Document.
Roadmap
- UI: Header (v0.1)
- UI: Tree Overview (v0.1)
- UI: Data Block (v0.1)
- UI: Footer to show current root and identify (and other messages) (v0.2)
- UI: Filter Input (v0.5)
- UI: Popup widget to show error or help messages (v0.2)
- UI: Highlight filtering keywords (v0.6)
- Action: Change current selected item as root (v0.1)
- Action: Back to previous root (v0.1)
- Action: Scale up/down tree widget (v0.1)
- Action: Mouse click actions
- Action: Mouse scroll actions
- Action: Open current selected item in editor ReadOnly (v0.2)
- Action: Switch between tree overview and data block (v0.1)
- Action: Jump to parent item (v0.1)
- Action: Jump to parent item and close (v0.1)
- Action: Expand selected item's children (v0.5)
- Action: Expand all items (v0.5)
- Action: Close all opened items (v0.1)
- Action: Popup to show help messages (v0.5)
- Action: Clipboard support, copy current item's content (might need to call external program like
wl-copy,pbcopy) (v0.2) - Syntax highlighting in data block (v0.2)
- Allow user to customize TUI colors and key bindings (and other things you can imagine) (v0.1)
- Filter items! (Like jnv) (v0.5)
- With
--debugflag, write some debug logs to a file (v0.4)
If you have any great ideas, please create an issue, thanks!
Thanks
I created this tool to better view those super deep YAML files of Kubernetes while jnv only supports JSON.
This is based on the amazing TUI framework ratatui and its tree widget tui-tree-widget.
