Skip to content

Commit

Permalink
feat(cli): add no-preview flag to disable the preview pane (#258)
Browse files Browse the repository at this point in the history
Fixes #255
  • Loading branch information
alexpasmantier authored Jan 9, 2025
1 parent b5e9846 commit ea8b955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/television/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions crates/television/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ea8b955

Please sign in to comment.