From ea8b955e6d34eade1f83de41805cbab6b7eb6335 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:29:32 +0100 Subject: [PATCH] feat(cli): add `no-preview` flag to disable the preview pane (#258) Fixes #255 --- crates/television/cli.rs | 8 ++++++++ crates/television/main.rs | 3 +++ 2 files changed, 11 insertions(+) diff --git a/crates/television/cli.rs b/crates/television/cli.rs index 0377220..186d1c8 100644 --- a/crates/television/cli.rs +++ b/crates/television/cli.rs @@ -26,6 +26,10 @@ pub struct Cli { #[arg(short, long, value_name = "STRING")] pub preview: Option, + /// Disable the preview pane + #[arg(long, default_value = "false")] + pub no_preview: bool, + /// The delimiter used to extract fields from the entry to provide to the preview command /// (defaults to ":") #[arg(long, value_name = "STRING", default_value = " ", value_parser = delimiter_parser)] @@ -99,6 +103,7 @@ impl From for UtilShell { pub struct PostProcessedCli { pub channel: ParsedCliChannel, pub preview_command: Option, + pub no_preview: bool, pub tick_rate: Option, pub frame_rate: Option, pub passthrough_keybindings: Vec, @@ -148,6 +153,7 @@ impl From for PostProcessedCli { Self { channel, preview_command, + no_preview: cli.no_preview, tick_rate: cli.tick_rate, frame_rate: cli.frame_rate, passthrough_keybindings, @@ -334,6 +340,7 @@ mod tests { let cli = Cli { channel: "files".to_string(), preview: Some("bat -n --color=always {}".to_string()), + no_preview: false, delimiter: ":".to_string(), tick_rate: Some(50.0), frame_rate: Some(60.0), @@ -375,6 +382,7 @@ mod tests { let cli = Cli { channel: ".".to_string(), preview: None, + no_preview: false, delimiter: ":".to_string(), tick_rate: Some(50.0), frame_rate: Some(60.0), diff --git a/crates/television/main.rs b/crates/television/main.rs index a900d45..1349209 100644 --- a/crates/television/main.rs +++ b/crates/television/main.rs @@ -65,6 +65,9 @@ async fn main() -> Result<()> { args.tick_rate.unwrap_or(config.config.tick_rate); config.config.frame_rate = args.frame_rate.unwrap_or(config.config.frame_rate); + if args.no_preview { + config.ui.show_preview_panel = false; + } if let Some(working_directory) = args.working_directory { let path = Path::new(&working_directory);