proof of concept: pass inline from channel

This commit is contained in:
Aiden Scandella 2025-07-20 08:33:34 -07:00
parent 1d6b996c83
commit 6195f2321b
No known key found for this signature in database
GPG Key ID: 17C559C421D83A19
5 changed files with 32 additions and 8 deletions

View File

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

View File

@ -463,11 +463,11 @@ pub struct Cli {
/// space to meet the minimum height the terminal will scroll.
#[arg(
long,
default_value = "false",
verbatim_doc_comment,
conflicts_with = "height"
conflicts_with = "height",
value_parser = clap::builder::FalseyValueParser::new()
)]
pub inline: bool,
pub inline: Option<bool>,
#[command(subcommand)]
pub command: Option<Command>,

View File

@ -88,7 +88,7 @@ pub struct PostProcessedCli {
pub ui_scale: Option<u16>,
pub height: Option<u16>,
pub width: Option<u16>,
pub inline: bool,
pub inline: Option<bool>,
// Behavior and matching configuration
pub exact: bool,
@ -160,7 +160,7 @@ impl Default for PostProcessedCli {
ui_scale: None,
height: None,
width: None,
inline: false,
inline: None,
// Behavior and matching configuration
exact: false,
@ -246,7 +246,10 @@ pub fn post_process(cli: Cli, readable_stdin: bool) -> PostProcessedCli {
validate_adhoc_mode_constraints(&cli, readable_stdin);
// Validate width flag requires inline or height
if cli.width.is_some() && !cli.inline && cli.height.is_none() {
if cli.width.is_some()
&& !cli.inline.unwrap_or(false)
&& cli.height.is_none()
{
cli_parsing_error_exit(
"--width can only be used in combination with --inline or --height",
);

View File

@ -111,6 +111,7 @@ pub struct UiConfig {
#[serde(default = "default_input_prompt")]
pub input_prompt: String,
pub features: Features,
pub inline: Option<bool>,
// 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,
}
}
}

View File

@ -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...");
@ -96,7 +99,7 @@ async fn main() -> Result<()> {
watch_interval,
args.height,
args.width,
args.inline,
args.inline.unwrap_or(false),
);
let mut app = App::new(
channel_prototype,
@ -135,6 +138,17 @@ async fn main() -> Result<()> {
exit(0);
}
fn apply_channel_overrides(
args: &mut PostProcessedCli,
channel_prototype: &ChannelPrototype,
) -> () {
if let Some(ui) = channel_prototype.ui.as_ref() {
if args.inline.is_none() {
args.inline = ui.inline;
}
}
}
/// Apply overrides from the CLI arguments to the configuration.
///
/// This function mutates the configuration in place.
@ -383,6 +397,7 @@ fn apply_ui_overrides(
status_bar: None,
help_panel: None,
remote_control: None,
inline: None,
});
// Apply input header override
@ -764,6 +779,7 @@ mod tests {
status_bar: None,
help_panel: None,
remote_control: None,
inline: None,
});
let cable = Cable::from_prototypes(vec![channel_prototype]);