feat(cli): add no-preview flag to disable the preview pane (#258)

Fixes #255
This commit is contained in:
Alex Pasmantier 2025-01-09 13:29:32 +01:00 committed by GitHub
parent b5e9846e1b
commit ea8b955e6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,10 @@ pub struct Cli {
#[arg(short, long, value_name = "STRING")]
pub preview: Option<String>,
/// 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<Shell> for UtilShell {
pub struct PostProcessedCli {
pub channel: ParsedCliChannel,
pub preview_command: Option<PreviewCommand>,
pub no_preview: bool,
pub tick_rate: Option<f64>,
pub frame_rate: Option<f64>,
pub passthrough_keybindings: Vec<String>,
@ -148,6 +153,7 @@ impl From<Cli> 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),

View File

@ -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);