feat(core): wire config editor into ProviderManager
Register ConfigProvider as built-in dynamic provider. Extend execute_plugin_action to dispatch CONFIG:* commands via the DynamicProvider::execute_action trait method.
This commit is contained in:
@@ -55,7 +55,7 @@ impl ConfigProvider {
|
||||
}
|
||||
|
||||
/// Execute a `CONFIG:*` action command. Returns `true` if handled.
|
||||
pub fn execute_action(&self, command: &str) -> bool {
|
||||
fn handle_config_action(&self, command: &str) -> bool {
|
||||
let Some(rest) = command.strip_prefix("CONFIG:") else {
|
||||
return false;
|
||||
};
|
||||
@@ -646,6 +646,10 @@ impl DynamicProvider for ConfigProvider {
|
||||
8000
|
||||
}
|
||||
|
||||
fn execute_action(&self, command: &str) -> bool {
|
||||
self.handle_config_action(command)
|
||||
}
|
||||
|
||||
fn query(&self, query: &str) -> Vec<LaunchItem> {
|
||||
let q = query.trim().to_lowercase();
|
||||
|
||||
|
||||
@@ -117,6 +117,11 @@ pub(crate) trait DynamicProvider: Send + Sync {
|
||||
fn provider_type(&self) -> ProviderType;
|
||||
fn query(&self, query: &str) -> Vec<LaunchItem>;
|
||||
fn priority(&self) -> u32;
|
||||
|
||||
/// Handle a plugin action command. Returns true if handled.
|
||||
fn execute_action(&self, _command: &str) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Manages all providers and handles searching
|
||||
@@ -328,6 +333,11 @@ impl ProviderManager {
|
||||
info!("Registered built-in converter provider");
|
||||
}
|
||||
|
||||
// Config editor — always enabled
|
||||
let config_arc = std::sync::Arc::new(std::sync::RwLock::new(config.clone()));
|
||||
builtin_dynamic.push(Box::new(config_editor::ConfigProvider::new(config_arc)));
|
||||
info!("Registered built-in config editor provider");
|
||||
|
||||
// Built-in static providers
|
||||
if config.providers.system {
|
||||
core_providers.push(Box::new(system::SystemProvider::new()));
|
||||
@@ -530,6 +540,14 @@ impl ProviderManager {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check built-in dynamic providers
|
||||
for provider in &self.builtin_dynamic {
|
||||
if provider.execute_action(command) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user