refactor: Trim whitespace from end of each line in table output
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -140,6 +140,14 @@ pub fn settings_output_format(settings: &config::Settings) -> OutputFormat {
|
|||||||
.unwrap_or(OutputFormat::Table)
|
.unwrap_or(OutputFormat::Table)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Trim whitespace from the end of each line in a string
|
||||||
|
pub fn trim_lines_end(s: &str) -> String {
|
||||||
|
s.lines()
|
||||||
|
.map(|line| line.trim_end())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a table with consistent styling and terminal detection
|
/// Create a table with consistent styling and terminal detection
|
||||||
pub fn create_table(use_styling: bool) -> Table {
|
pub fn create_table(use_styling: bool) -> Table {
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ fn show_item(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&table.trim_fmt()));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ pub fn mode_list(
|
|||||||
table.add_row(table_row);
|
table.add_row(table_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&table.trim_fmt()));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,18 +210,18 @@ pub fn mode_status(
|
|||||||
OutputFormat::Table => {
|
OutputFormat::Table => {
|
||||||
println!("CONFIG:");
|
println!("CONFIG:");
|
||||||
let config_table = build_config_table(settings);
|
let config_table = build_config_table(settings);
|
||||||
println!("{}", config_table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&config_table.trim_fmt()));
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
println!("PATHS:");
|
println!("PATHS:");
|
||||||
let path_table = build_path_table(&status_info.paths);
|
let path_table = build_path_table(&status_info.paths);
|
||||||
println!("{}", path_table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&path_table.trim_fmt()));
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
// Always try to print META PLUGINS CONFIGURED section using status_info
|
// Always try to print META PLUGINS CONFIGURED section using status_info
|
||||||
if let Some(meta_plugins_table) = build_meta_plugins_configured_table(&status_info) {
|
if let Some(meta_plugins_table) = build_meta_plugins_configured_table(&status_info) {
|
||||||
println!("META PLUGINS CONFIGURED:");
|
println!("META PLUGINS CONFIGURED:");
|
||||||
println!("{}", meta_plugins_table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&meta_plugins_table.trim_fmt()));
|
||||||
println!();
|
println!();
|
||||||
} else {
|
} else {
|
||||||
println!("META PLUGINS CONFIGURED:");
|
println!("META PLUGINS CONFIGURED:");
|
||||||
|
|||||||
@@ -262,17 +262,17 @@ pub fn mode_status_plugins(
|
|||||||
println!("META PLUGINS:");
|
println!("META PLUGINS:");
|
||||||
println!("META PLUGINS:");
|
println!("META PLUGINS:");
|
||||||
let meta_table = build_meta_plugin_table(&status_info.meta_plugins);
|
let meta_table = build_meta_plugin_table(&status_info.meta_plugins);
|
||||||
println!("{}", meta_table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&meta_table.trim_fmt()));
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
println!("COMPRESSION PLUGINS:");
|
println!("COMPRESSION PLUGINS:");
|
||||||
let compression_table = build_compression_table(&status_info.compression);
|
let compression_table = build_compression_table(&status_info.compression);
|
||||||
println!("{}", compression_table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&compression_table.trim_fmt()));
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
println!("FILTER PLUGINS:");
|
println!("FILTER PLUGINS:");
|
||||||
let filter_table = build_filter_plugin_table(&status_info.filter_plugins);
|
let filter_table = build_filter_plugin_table(&status_info.filter_plugins);
|
||||||
println!("{}", filter_table.trim_fmt().trim_end());
|
println!("{}", crate::modes::common::trim_lines_end(&filter_table.trim_fmt()));
|
||||||
println!();
|
println!();
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user