7 ms·
I also wish for a rust replacement of lnav! (I'm the author) I actually started working on one earlier this year and made some progress before getting distrac
by tstack 3y ago
I also wish for a rust replacement of lnav! (I'm the author)
I actually started working on one earlier this year and made some progress before getting distracted. I was using tui-rs, which then got forked to ratatui. I should check back in with it sometime soon.
- hiAndrewQuinn 3y agoDid you run into any huge roadblocks when you were trying to port the C++ codebase? I've really been digging `lnav` for the last few days - it gives me a sizeable fraction of Datadog's power in my tiny new embedded world.
- tstack 3y agoYes, there were some roadblocks and that made me lose some steam. What's kinda funny is that I spent a lot of time trying to make pretty errors[1] in lnav as inspired by rustc, but had a hard time replicating that in the rust ecosystem. For example, I was using serde to parse lnav's JSON configuration files, but getting serde to report line numbers (and/or a JSON path) for errors was pretty difficult. I think serde was also missing a way to report multiple errors. Otherwise, I had wanted to do some rearchitecting to do log parsing in background threads since it's largely sync in the C++ version. Doing that in rust was great since the borrow-checker guided me down a sane path. [1] - https://lnav.org/2022/08/04/pretty-errors.html https://lnav.org/2022/08/04/pretty-errors.html
- joshka 3y agoI've been meaning to have a play with miette for a while: fn main() -> Result<()> { let config: Config = serde_json::from_str(DATA).map_err(|e| BadJson::from_json_err(e, DATA))?; Ok(()) } #[derive(Debug, Error, Diagnostic)] #[error("Received some unexpected JSON.")] #[diagnostic( code(some::app::bad_json), url("https://my-app.com/some-json-error"), help("Fix the JSON.",) )] struct BadJson { source: serde_json::Error, #[source_code] json: NamedSource, #[label("here")] err_loc: (usize, usize), } impl BadJson { fn from_json_err(err: serde_json::error::Error, json: &str) -> Self { let offset = SourceOffset::from_location(json, err.line(), err.column()); Self { source: err, json: NamedSource::new("config.json", json.to_string()), err_loc: (offset.offset(), 0), } } } Generates: Error: some::app::bad_json (https://my-app.com/some-json-error) × Received some unexpected JSON. ╰─▶ invalid type: integer `123`, expected a string at line 13 column 51 ╭─[config.json:12:1] 12 │ "color": "#f6f6f6", 13 │ "background-color": 123 · ▲ · ╰── here 14 │ } ╰──── help: Fix the JSON.
- joshka 3y agoAs it happens, I'm one of the maintainers of Ratatui, so it's been a little bit more than an idle thought... If you do happen to find time to revive the project I'd be happy to help. Come say hi on the ratatui discord / matrix.