refactor: Centralize status info retrieval in status service
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -129,8 +129,8 @@ fn build_config_table(settings: &config::Settings) -> Table {
|
||||
config_table
|
||||
}
|
||||
|
||||
fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Table> {
|
||||
let meta_plugins = settings.meta_plugins.as_ref()?;
|
||||
fn build_meta_plugins_configured_table(status_info: &StatusInfo) -> Option<Table> {
|
||||
let meta_plugins = status_info.configured_meta_plugins.as_ref()?;
|
||||
if meta_plugins.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -297,8 +297,8 @@ pub fn mode_status(
|
||||
build_path_table(&status_info.paths).printstd();
|
||||
println!();
|
||||
|
||||
// Always try to print META PLUGINS CONFIGURED section
|
||||
if let Some(meta_plugins_table) = build_meta_plugins_configured_table(settings) {
|
||||
// Always try to print META PLUGINS CONFIGURED section using status_info
|
||||
if let Some(meta_plugins_table) = build_meta_plugins_configured_table(&status_info) {
|
||||
println!("META PLUGINS CONFIGURED:");
|
||||
meta_plugins_table.printstd();
|
||||
println!();
|
||||
@@ -310,6 +310,7 @@ pub fn mode_status(
|
||||
Ok(())
|
||||
},
|
||||
OutputFormat::Json => {
|
||||
// Create a subset for status info that includes everything
|
||||
println!("{}", serde_json::to_string_pretty(&status_info)?);
|
||||
Ok(())
|
||||
},
|
||||
|
||||
@@ -220,17 +220,17 @@ pub fn mode_status_plugins(
|
||||
Ok(())
|
||||
},
|
||||
OutputFormat::Json => {
|
||||
// Create a subset for plugins only
|
||||
// Create a subset for plugins only using status_info
|
||||
let plugins_info = serde_json::json!({
|
||||
"meta_plugins_available": status_info.meta_plugins,
|
||||
"meta_plugins_configured": settings.meta_plugins,
|
||||
"meta_plugins_configured": status_info.configured_meta_plugins,
|
||||
"filter_plugins": status_info.filter_plugins
|
||||
});
|
||||
println!("{}", serde_json::to_string_pretty(&plugins_info)?);
|
||||
Ok(())
|
||||
},
|
||||
OutputFormat::Yaml => {
|
||||
// Create a proper structure for plugins info
|
||||
// Create a proper structure for plugins info using status_info
|
||||
use serde_yaml::Mapping;
|
||||
let mut plugins_mapping = Mapping::new();
|
||||
|
||||
@@ -241,7 +241,7 @@ pub fn mode_status_plugins(
|
||||
);
|
||||
|
||||
// Add configured plugins if they exist
|
||||
if let Some(configured_plugins) = &settings.meta_plugins {
|
||||
if let Some(configured_plugins) = &status_info.configured_meta_plugins {
|
||||
plugins_mapping.insert(
|
||||
serde_yaml::Value::String("meta_plugins_configured".to_string()),
|
||||
serde_yaml::to_value(configured_plugins)?,
|
||||
|
||||
Reference in New Issue
Block a user