diff --git a/television/channels/prototypes.rs b/television/channels/prototypes.rs index f44c823..3f43ebc 100644 --- a/television/channels/prototypes.rs +++ b/television/channels/prototypes.rs @@ -401,6 +401,8 @@ pub struct UiSpec { pub help_panel: Option, #[serde(default)] pub remote_control: Option, + #[serde(default)] + pub inline: Option, } pub const DEFAULT_PROTOTYPE_NAME: &str = "files"; @@ -418,6 +420,7 @@ impl From<&crate::config::UiConfig> for UiSpec { status_bar: Some(config.status_bar.clone()), help_panel: Some(config.help_panel.clone()), remote_control: Some(config.remote_control.clone()), + inline: config.inline, } } } diff --git a/television/config/ui.rs b/television/config/ui.rs index 55ae396..c919526 100644 --- a/television/config/ui.rs +++ b/television/config/ui.rs @@ -111,6 +111,7 @@ pub struct UiConfig { #[serde(default = "default_input_prompt")] pub input_prompt: String, pub features: Features, + pub inline: Option, // Feature-specific configurations pub status_bar: StatusBarConfig, @@ -144,6 +145,7 @@ impl Default for UiConfig { help_panel: HelpPanelConfig::default(), remote_control: RemoteControlConfig::default(), theme_overrides: ThemeOverrides::default(), + inline: None, } } } diff --git a/television/main.rs b/television/main.rs index 5685c11..fdaea8c 100644 --- a/television/main.rs +++ b/television/main.rs @@ -46,7 +46,7 @@ async fn main() -> Result<()> { let readable_stdin = is_readable_stdin(); - let args = post_process(cli, readable_stdin); + let mut args = post_process(cli, readable_stdin); debug!("PostProcessedCli: {:?}", args); // load the configuration file @@ -78,6 +78,9 @@ async fn main() -> Result<()> { let channel_prototype = determine_channel(&args, &config, readable_stdin, Some(&cable)); + // allow channel to override CLI arguments + apply_channel_overrides(&mut args, &channel_prototype); + CLIPBOARD.with(<_>::default); debug!("Creating application..."); @@ -135,6 +138,23 @@ async fn main() -> Result<()> { exit(0); } +fn apply_channel_overrides( + args: &mut PostProcessedCli, + channel_prototype: &ChannelPrototype, +) -> () { + // The default value for CLI args inline is `false`. If the CLI arguments have + // specified --inline, we should always take that value and ignore what the chanel wants + if args.inline { + return; + } + if let Some(ui) = channel_prototype.ui.as_ref() { + // Otherwise, if the channel has specified an inline value, take it + if let Some(inline) = ui.inline { + args.inline = inline + } + } +} + /// Apply overrides from the CLI arguments to the configuration. /// /// This function mutates the configuration in place. @@ -383,6 +403,7 @@ fn apply_ui_overrides( status_bar: None, help_panel: None, remote_control: None, + inline: None, }); // Apply input header override @@ -764,6 +785,7 @@ mod tests { status_bar: None, help_panel: None, remote_control: None, + inline: None, }); let cable = Cable::from_prototypes(vec![channel_prototype]);