fix: Resolve serde type mismatches and remove unused imports
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -7,14 +7,12 @@ use log::debug;
|
|||||||
use crate::modes::common::{get_format_box_chars_no_border_line_separator, OutputFormat};
|
use crate::modes::common::{get_format_box_chars_no_border_line_separator, OutputFormat};
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::common::status::StatusInfo;
|
use crate::common::status::StatusInfo;
|
||||||
use prettytable::color;
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use serde_yaml;
|
use serde_yaml;
|
||||||
use prettytable::row;
|
|
||||||
use prettytable::{Attr, Cell, Row, Table};
|
use prettytable::{Attr, Cell, Row, Table};
|
||||||
use prettytable::format::consts::{FORMAT_NO_BORDER_LINE_SEPARATOR};
|
use prettytable::format::consts::{FORMAT_NO_BORDER_LINE_SEPARATOR};
|
||||||
|
|
||||||
use crate::common::status::{PathInfo, CompressionInfo};
|
use crate::common::status::PathInfo;
|
||||||
use crate::meta_plugin::MetaPluginType;
|
use crate::meta_plugin::MetaPluginType;
|
||||||
use crate::meta_plugin::get_meta_plugin;
|
use crate::meta_plugin::get_meta_plugin;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,41 @@ use std::path::PathBuf;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
|
// Helper function to convert serde_json::Value to serde_yaml::Value
|
||||||
|
fn convert_json_to_yaml_value(value: &serde_json::Value) -> serde_yaml::Value {
|
||||||
|
match value {
|
||||||
|
serde_json::Value::Null => serde_yaml::Value::Null,
|
||||||
|
serde_json::Value::Bool(b) => serde_yaml::Value::Bool(*b),
|
||||||
|
serde_json::Value::Number(n) => {
|
||||||
|
if let Some(i) = n.as_i64() {
|
||||||
|
serde_yaml::Value::Number(serde_yaml::Number::from(i))
|
||||||
|
} else if let Some(f) = n.as_f64() {
|
||||||
|
serde_yaml::Value::Number(serde_yaml::Number::from(f))
|
||||||
|
} else {
|
||||||
|
serde_yaml::Value::String(n.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serde_json::Value::String(s) => serde_yaml::Value::String(s.clone()),
|
||||||
|
serde_json::Value::Array(arr) => {
|
||||||
|
let mut yaml_array = Vec::new();
|
||||||
|
for item in arr {
|
||||||
|
yaml_array.push(convert_json_to_yaml_value(item));
|
||||||
|
}
|
||||||
|
serde_yaml::Value::Sequence(yaml_array)
|
||||||
|
}
|
||||||
|
serde_json::Value::Object(obj) => {
|
||||||
|
let mut yaml_mapping = serde_yaml::Mapping::new();
|
||||||
|
for (k, v) in obj {
|
||||||
|
yaml_mapping.insert(
|
||||||
|
serde_yaml::Value::String(k.clone()),
|
||||||
|
convert_json_to_yaml_value(v),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
serde_yaml::Value::Mapping(yaml_mapping)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use crate::modes::common::OutputFormat;
|
use crate::modes::common::OutputFormat;
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
@@ -146,14 +181,60 @@ fn build_filter_plugin_table(filter_plugins: &Vec<crate::common::status::FilterP
|
|||||||
// Convert options to a proper structure for display
|
// Convert options to a proper structure for display
|
||||||
let mut options_list = Vec::new();
|
let mut options_list = Vec::new();
|
||||||
for opt in &plugin_info.options {
|
for opt in &plugin_info.options {
|
||||||
let mut opt_map = std::collections::BTreeMap::new();
|
let mut opt_map = serde_yaml::Mapping::new();
|
||||||
opt_map.insert("name".to_string(), serde_yaml::Value::String(opt.name.clone()));
|
opt_map.insert(
|
||||||
|
serde_yaml::Value::String("name".to_string()),
|
||||||
|
serde_yaml::Value::String(opt.name.clone()),
|
||||||
|
);
|
||||||
if let Some(default) = &opt.default {
|
if let Some(default) = &opt.default {
|
||||||
opt_map.insert("default".to_string(), default.clone());
|
// Convert serde_json::Value to serde_yaml::Value
|
||||||
|
let yaml_value = match default {
|
||||||
|
serde_json::Value::Null => serde_yaml::Value::Null,
|
||||||
|
serde_json::Value::Bool(b) => serde_yaml::Value::Bool(*b),
|
||||||
|
serde_json::Value::Number(n) => {
|
||||||
|
if let Some(i) = n.as_i64() {
|
||||||
|
serde_yaml::Value::Number(serde_yaml::Number::from(i))
|
||||||
|
} else if let Some(f) = n.as_f64() {
|
||||||
|
serde_yaml::Value::Number(serde_yaml::Number::from(f))
|
||||||
|
} else {
|
||||||
|
serde_yaml::Value::String(default.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serde_json::Value::String(s) => serde_yaml::Value::String(s.clone()),
|
||||||
|
serde_json::Value::Array(arr) => {
|
||||||
|
// Convert each element in the array
|
||||||
|
let mut yaml_array = Vec::new();
|
||||||
|
for item in arr {
|
||||||
|
yaml_array.push(convert_json_to_yaml_value(item));
|
||||||
|
}
|
||||||
|
serde_yaml::Value::Sequence(yaml_array)
|
||||||
|
}
|
||||||
|
serde_json::Value::Object(obj) => {
|
||||||
|
// Convert each key-value pair in the object
|
||||||
|
let mut yaml_mapping = serde_yaml::Mapping::new();
|
||||||
|
for (k, v) in obj {
|
||||||
|
yaml_mapping.insert(
|
||||||
|
serde_yaml::Value::String(k.clone()),
|
||||||
|
convert_json_to_yaml_value(v),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
serde_yaml::Value::Mapping(yaml_mapping)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
opt_map.insert(
|
||||||
|
serde_yaml::Value::String("default".to_string()),
|
||||||
|
yaml_value,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
opt_map.insert("default".to_string(), serde_yaml::Value::Null);
|
opt_map.insert(
|
||||||
|
serde_yaml::Value::String("default".to_string()),
|
||||||
|
serde_yaml::Value::Null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
opt_map.insert("required".to_string(), serde_yaml::Value::Bool(opt.required));
|
opt_map.insert(
|
||||||
|
serde_yaml::Value::String("required".to_string()),
|
||||||
|
serde_yaml::Value::Bool(opt.required),
|
||||||
|
);
|
||||||
options_list.push(serde_yaml::Value::Mapping(opt_map));
|
options_list.push(serde_yaml::Value::Mapping(opt_map));
|
||||||
}
|
}
|
||||||
serde_yaml::to_string(&serde_yaml::Value::Sequence(options_list))
|
serde_yaml::to_string(&serde_yaml::Value::Sequence(options_list))
|
||||||
|
|||||||
Reference in New Issue
Block a user