feat: sort and format meta plugins table outputs
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -196,17 +196,22 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Ta
|
||||
all_options.insert(key.clone(), value.clone());
|
||||
}
|
||||
|
||||
// Convert options to a YAML string
|
||||
let options_str = if all_options.is_empty() {
|
||||
// Sort options by key and convert to a YAML string
|
||||
let mut sorted_options: Vec<_> = all_options.iter().collect();
|
||||
sorted_options.sort_by(|a, b| a.0.cmp(b.0));
|
||||
let sorted_options_map: std::collections::BTreeMap<_, _> = sorted_options.into_iter().collect();
|
||||
|
||||
let options_str = if sorted_options_map.is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
serde_yaml::to_string(&all_options)
|
||||
serde_yaml::to_string(&sorted_options_map)
|
||||
.unwrap_or_else(|_| "Unable to serialize options".to_string())
|
||||
.trim()
|
||||
.to_string()
|
||||
};
|
||||
|
||||
// Show only non-null outputs from the plugin
|
||||
// Collect and sort outputs by their string representation
|
||||
let mut enabled_output_pairs = Vec::new();
|
||||
for (key, value) in actual_plugin.outputs() {
|
||||
// Skip null values (disabled outputs)
|
||||
@@ -233,16 +238,23 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Ta
|
||||
// Trim any extra whitespace from the serialized values
|
||||
let value_str = value_str.trim().to_string();
|
||||
if key == &value_str {
|
||||
enabled_output_pairs.push(key.clone());
|
||||
enabled_output_pairs.push((key.clone(), key.clone()));
|
||||
} else {
|
||||
enabled_output_pairs.push(format!("{}->{}", key, value_str));
|
||||
enabled_output_pairs.push((key.clone(), format!("{}->{}", key, value_str)));
|
||||
}
|
||||
}
|
||||
|
||||
// Sort outputs by their display value (second element of the tuple)
|
||||
enabled_output_pairs.sort_by(|a, b| a.1.cmp(&b.1));
|
||||
|
||||
// Join each output on a new line
|
||||
let outputs_str = if enabled_output_pairs.is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
enabled_output_pairs.join(", ")
|
||||
enabled_output_pairs.into_iter()
|
||||
.map(|(_, display)| display)
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
};
|
||||
|
||||
table.add_row(Row::new(vec![
|
||||
|
||||
Reference in New Issue
Block a user