Merge 339c374127838de065a5a92506f546876891fa97 into be6cdf8a3a4dff6bd72037a6b3b98370e84cee0d

This commit is contained in:
Aiden Scandella 2025-07-23 06:53:39 +02:00 committed by GitHub
commit bb0fca5196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 1 deletions

View File

@ -401,6 +401,8 @@ pub struct UiSpec {
pub help_panel: Option<ui::HelpPanelConfig>, pub help_panel: Option<ui::HelpPanelConfig>,
#[serde(default)] #[serde(default)]
pub remote_control: Option<ui::RemoteControlConfig>, pub remote_control: Option<ui::RemoteControlConfig>,
#[serde(default)]
pub inline: Option<bool>,
} }
pub const DEFAULT_PROTOTYPE_NAME: &str = "files"; 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()), status_bar: Some(config.status_bar.clone()),
help_panel: Some(config.help_panel.clone()), help_panel: Some(config.help_panel.clone()),
remote_control: Some(config.remote_control.clone()), remote_control: Some(config.remote_control.clone()),
inline: config.inline,
} }
} }
} }

View File

@ -111,6 +111,7 @@ pub struct UiConfig {
#[serde(default = "default_input_prompt")] #[serde(default = "default_input_prompt")]
pub input_prompt: String, pub input_prompt: String,
pub features: Features, pub features: Features,
pub inline: Option<bool>,
// Feature-specific configurations // Feature-specific configurations
pub status_bar: StatusBarConfig, pub status_bar: StatusBarConfig,
@ -144,6 +145,7 @@ impl Default for UiConfig {
help_panel: HelpPanelConfig::default(), help_panel: HelpPanelConfig::default(),
remote_control: RemoteControlConfig::default(), remote_control: RemoteControlConfig::default(),
theme_overrides: ThemeOverrides::default(), theme_overrides: ThemeOverrides::default(),
inline: None,
} }
} }
} }

View File

@ -46,7 +46,7 @@ async fn main() -> Result<()> {
let readable_stdin = is_readable_stdin(); let readable_stdin = is_readable_stdin();
let args = post_process(cli, readable_stdin); let mut args = post_process(cli, readable_stdin);
debug!("PostProcessedCli: {:?}", args); debug!("PostProcessedCli: {:?}", args);
// load the configuration file // load the configuration file
@ -78,6 +78,9 @@ async fn main() -> Result<()> {
let channel_prototype = let channel_prototype =
determine_channel(&args, &config, readable_stdin, Some(&cable)); determine_channel(&args, &config, readable_stdin, Some(&cable));
// allow channel to override CLI arguments
apply_channel_overrides(&mut args, &channel_prototype);
CLIPBOARD.with(<_>::default); CLIPBOARD.with(<_>::default);
debug!("Creating application..."); debug!("Creating application...");
@ -135,6 +138,23 @@ async fn main() -> Result<()> {
exit(0); 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. /// Apply overrides from the CLI arguments to the configuration.
/// ///
/// This function mutates the configuration in place. /// This function mutates the configuration in place.
@ -383,6 +403,7 @@ fn apply_ui_overrides(
status_bar: None, status_bar: None,
help_panel: None, help_panel: None,
remote_control: None, remote_control: None,
inline: None,
}); });
// Apply input header override // Apply input header override
@ -764,6 +785,7 @@ mod tests {
status_bar: None, status_bar: None,
help_panel: None, help_panel: None,
remote_control: None, remote_control: None,
inline: None,
}); });
let cable = Cable::from_prototypes(vec![channel_prototype]); let cable = Cable::from_prototypes(vec![channel_prototype]);