Skip to main content

ito_core/viewer/
bat.rs

1use crate::errors::CoreResult;
2
3use super::ViewerBackend;
4use super::util::{command_on_path, run_with_stdin};
5
6/// Render markdown via `bat` with paging.
7pub struct BatViewer;
8
9impl ViewerBackend for BatViewer {
10    fn name(&self) -> &str {
11        "bat"
12    }
13
14    fn description(&self) -> &str {
15        "Render the proposal in the terminal with bat"
16    }
17
18    fn is_available(&self) -> bool {
19        command_on_path("bat")
20    }
21
22    fn open(&self, content: &str) -> CoreResult<()> {
23        run_with_stdin("bat", &["--language=markdown", "--paging=always"], content)
24    }
25}