From 1957d8d6eec165075e1e67c9f64d9b65ea6931c6 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier Date: Sun, 27 Jul 2025 01:01:56 +0200 Subject: [PATCH] WIP --- benches/main/ui.rs | 4 +- television/app.rs | 4 +- television/cli/args.rs | 34 +- television/cli/mod.rs | 655 +++++++++++++++------------------------ television/config/mod.rs | 4 +- television/main.rs | 97 +++--- television/television.rs | 18 +- tests/app.rs | 6 +- 8 files changed, 339 insertions(+), 483 deletions(-) diff --git a/benches/main/ui.rs b/benches/main/ui.rs index c7232b0..c3ea683 100644 --- a/benches/main/ui.rs +++ b/benches/main/ui.rs @@ -16,7 +16,7 @@ use television::{ action::Action, cable::Cable, channels::entry::{Entry, into_ranges}, - cli::PostProcessedCli, + cli::ProcessedCli, config::{Config, ConfigEnv}, screen::{colors::ResultsColorscheme, result_item::build_results_list}, television::Television, @@ -486,7 +486,7 @@ pub fn draw(c: &mut Criterion) { channel_prototype, config, cable.clone(), - PostProcessedCli::default(), + ProcessedCli::default(), ); tv.find("television"); for _ in 0..5 { diff --git a/television/app.rs b/television/app.rs index 06f6d2b..64218d6 100644 --- a/television/app.rs +++ b/television/app.rs @@ -2,7 +2,7 @@ use crate::{ action::Action, cable::Cable, channels::{entry::Entry, prototypes::ChannelPrototype}, - cli::PostProcessedCli, + cli::ProcessedCli, config::{Config, DEFAULT_PREVIEW_SIZE, default_tick_rate}, event::{Event, EventLoop, InputEvent, Key, MouseInputEvent}, history::History, @@ -190,7 +190,7 @@ impl App { config: Config, options: AppOptions, cable_channels: Cable, - cli_args: &PostProcessedCli, + cli_args: &ProcessedCli, ) -> Self { let (action_tx, action_rx) = mpsc::unbounded_channel(); let (render_tx, render_rx) = mpsc::unbounded_channel(); diff --git a/television/cli/args.rs b/television/cli/args.rs index 7030eaf..eb01629 100644 --- a/television/cli/args.rs +++ b/television/cli/args.rs @@ -36,17 +36,6 @@ pub struct Cli { #[arg(index = 1, verbatim_doc_comment)] pub channel: Option, - /// A preview line number offset template to use to scroll the preview to for each - /// entry. - /// - /// When a channel is specified: This overrides the offset defined in the channel prototype. - /// When no channel is specified: This flag requires --preview-command to be set. - /// - /// This template uses the same syntax as the `preview` option and will be formatted - /// using the currently selected entry. - #[arg(long, value_name = "STRING", verbatim_doc_comment)] - pub preview_offset: Option, - /// Disable the preview panel entirely on startup. /// /// This flag works identically in both channel mode and ad-hoc mode. @@ -310,6 +299,29 @@ pub struct Cli { )] pub preview_command: Option, + /// A preview line number offset template to use to scroll the preview to for each + /// entry. + /// + /// When a channel is specified: This overrides the offset defined in the channel prototype. + /// When no channel is specified: This flag requires --preview-command to be set. + /// + /// This template uses the same syntax as the `preview` option and will be formatted + /// using the currently selected entry. + #[arg(long, value_name = "STRING", verbatim_doc_comment)] + pub preview_offset: Option, + + /// Whether to cache the preview command output. + /// + /// This can be useful when the preview command is expensive to run or when the + /// output is static and doesn't change often. + #[arg( + long, + default_value = "false", + verbatim_doc_comment, + conflicts_with = "no_preview" + )] + pub preview_cached: bool, + /// Layout orientation for the UI. /// /// When a channel is specified: Overrides the layout/orientation defined in the channel prototype. diff --git a/television/cli/mod.rs b/television/cli/mod.rs index b5dae8a..0cf4ee8 100644 --- a/television/cli/mod.rs +++ b/television/cli/mod.rs @@ -4,8 +4,7 @@ use crate::{ channels::prototypes::{ChannelPrototype, Template}, cli::args::{Cli, Command}, config::{ - DEFAULT_PREVIEW_SIZE, KeyBindings, get_config_dir, get_data_dir, - merge_bindings, + KeyBindings, get_config_dir, get_data_dir, merge_bindings, shell_integration::ShellIntegrationConfig, ui::{BorderType, Padding}, }, @@ -26,269 +25,131 @@ use tracing::debug; pub mod args; -pub struct ChannelArguments { - pub channel: Option, - pub working_directory: Option, - pub prototype: Option, - pub no_preview: bool, - pub hide_preview: bool, - pub show_preview: bool, - pub preview_size: Option, - pub preview_header: Option, - pub preview_footer: Option, - pub autocomplete_prompt: Option, -} - -struct CliPrototype { - // source - pub source_command: Option