diff --git a/benches/main/ui.rs b/benches/main/ui.rs index 8e095f4..c7232b0 100644 --- a/benches/main/ui.rs +++ b/benches/main/ui.rs @@ -466,7 +466,7 @@ pub fn draw(c: &mut Criterion) { let rt = Runtime::new().unwrap(); - let cable = Cable::from_prototypes(vec![ChannelPrototype::new( + let cable = Cable::from_prototypes(vec![ChannelPrototype::simple( "files", "fd -t f", )]); diff --git a/television/channels/prototypes.rs b/television/channels/prototypes.rs index b05100f..bb31621 100644 --- a/television/channels/prototypes.rs +++ b/television/channels/prototypes.rs @@ -202,7 +202,19 @@ pub struct ChannelPrototype { } impl ChannelPrototype { - pub fn new(name: &str, command: &str) -> Self { + pub fn new(metadata: Metadata, source: SourceSpec) -> Self { + Self { + metadata, + source, + preview: None, + ui: None, + keybindings: None, + watch: 0.0, + history: HistoryConfig::default(), + } + } + + pub fn simple(name: &str, command: &str) -> Self { Self { metadata: Metadata { name: name.to_string(), @@ -231,10 +243,7 @@ impl ChannelPrototype { } } - pub fn stdin( - preview: Option, - entry_delimiter: Option, - ) -> Self { + pub fn stdin(entry_delimiter: Option) -> Self { Self { metadata: Metadata { name: "stdin".to_string(), @@ -254,7 +263,7 @@ impl ChannelPrototype { display: None, output: None, }, - preview, + preview: None, ui: None, keybindings: None, watch: 0.0, @@ -262,6 +271,19 @@ impl ChannelPrototype { } } + pub fn with_ui_options(mut self, ui: UiSpec) -> Self { + self.ui = Some(ui); + self + } + + pub fn with_keybindings( + mut self, + keybindings: ChannelKeyBindings, + ) -> Self { + self.keybindings = Some(keybindings); + self + } + pub fn with_preview(mut self, preview: Option) -> Self { self.preview = preview; self diff --git a/television/cli/mod.rs b/television/cli/mod.rs index f42e5b6..b5dae8a 100644 --- a/television/cli/mod.rs +++ b/television/cli/mod.rs @@ -6,6 +6,7 @@ use crate::{ config::{ DEFAULT_PREVIEW_SIZE, KeyBindings, get_config_dir, get_data_dir, merge_bindings, + shell_integration::ShellIntegrationConfig, ui::{BorderType, Padding}, }, errors::cli_parsing_error_exit, @@ -17,7 +18,6 @@ use anyhow::{Result, anyhow}; use clap::CommandFactory; use clap::error::ErrorKind; use colored::Colorize; -use rustc_hash::FxHashMap; use std::{ path::{Path, PathBuf}, str::FromStr, @@ -26,6 +26,35 @@ 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