refactor: rename command plugin to exec

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 22:01:47 -03:00
parent e374e2d99b
commit 15baa8f297
2 changed files with 20 additions and 20 deletions

View File

@@ -5,7 +5,7 @@ use which::which;
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse, MetaPluginType}; use crate::meta_plugin::{MetaPlugin, MetaPluginResponse, MetaPluginType};
pub struct MetaPluginCommand { pub struct MetaPluginExec {
pub program: String, pub program: String,
pub args: Vec<String>, pub args: Vec<String>,
pub supported: bool, pub supported: bool,
@@ -18,9 +18,9 @@ pub struct MetaPluginCommand {
} }
// Manual Debug implementation because Box<dyn Write> doesn't implement Debug // Manual Debug implementation because Box<dyn Write> doesn't implement Debug
impl std::fmt::Debug for MetaPluginCommand { impl std::fmt::Debug for MetaPluginExec {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MetaPluginCommand") f.debug_struct("MetaPluginExec")
.field("program", &self.program) .field("program", &self.program)
.field("args", &self.args) .field("args", &self.args)
.field("supported", &self.supported) .field("supported", &self.supported)
@@ -35,7 +35,7 @@ impl std::fmt::Debug for MetaPluginCommand {
} }
impl MetaPluginCommand { impl MetaPluginExec {
pub fn new( pub fn new(
program: &str, program: &str,
args: Vec<&str>, args: Vec<&str>,
@@ -43,7 +43,7 @@ impl MetaPluginCommand {
split_whitespace: bool, split_whitespace: bool,
_options: Option<std::collections::HashMap<String, serde_yaml::Value>>, _options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>, outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
) -> MetaPluginCommand { ) -> MetaPluginExec {
let program_path = which(program); let program_path = which(program);
let supported = program_path.is_ok(); let supported = program_path.is_ok();
@@ -64,7 +64,7 @@ impl MetaPluginCommand {
} }
} }
MetaPluginCommand { MetaPluginExec {
program: program_path.map_or_else(|_| program.to_string(), |p| p.to_string_lossy().to_string()), program: program_path.map_or_else(|_| program.to_string(), |p| p.to_string_lossy().to_string()),
args: args.iter().map(|s| s.to_string()).collect(), args: args.iter().map(|s| s.to_string()).collect(),
supported, supported,
@@ -79,7 +79,7 @@ impl MetaPluginCommand {
} }
impl MetaPlugin for MetaPluginCommand { impl MetaPlugin for MetaPluginExec {
fn is_supported(&self) -> bool { fn is_supported(&self) -> bool {
self.supported self.supported
} }
@@ -193,7 +193,7 @@ impl MetaPlugin for MetaPluginCommand {
} }
fn meta_type(&self) -> MetaPluginType { fn meta_type(&self) -> MetaPluginType {
MetaPluginType::Command MetaPluginType::Exec
} }
fn program_info(&self) -> Option<(&str, Vec<&str>)> { fn program_info(&self) -> Option<(&str, Vec<&str>)> {

View File

@@ -1,7 +1,7 @@
use log::debug; use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub mod command; pub mod exec;
pub mod digest; pub mod digest;
pub mod magic; pub mod magic;
pub mod binary; pub mod binary;
@@ -15,7 +15,7 @@ pub mod shell;
pub mod shell_pid; pub mod shell_pid;
pub mod keep_pid; pub mod keep_pid;
use crate::meta_plugin::command::MetaPluginCommand; use crate::meta_plugin::exec::MetaPluginExec;
use crate::meta_plugin::digest::DigestMetaPlugin; use crate::meta_plugin::digest::DigestMetaPlugin;
use crate::meta_plugin::read_time::ReadTimeMetaPlugin; use crate::meta_plugin::read_time::ReadTimeMetaPlugin;
use crate::meta_plugin::read_rate::ReadRateMetaPlugin; use crate::meta_plugin::read_rate::ReadRateMetaPlugin;
@@ -133,7 +133,7 @@ pub enum MetaPluginType {
ReadTime, ReadTime,
ReadRate, ReadRate,
Hostname, Hostname,
Command, Exec,
} }
/// Central function to handle metadata output with name mapping /// Central function to handle metadata output with name mapping
@@ -291,11 +291,11 @@ pub fn get_meta_plugin(
MetaPluginType::ReadTime => Box::new(ReadTimeMetaPlugin::new(options, outputs)), MetaPluginType::ReadTime => Box::new(ReadTimeMetaPlugin::new(options, outputs)),
MetaPluginType::ReadRate => Box::new(ReadRateMetaPlugin::new(options, outputs)), MetaPluginType::ReadRate => Box::new(ReadRateMetaPlugin::new(options, outputs)),
MetaPluginType::Hostname => Box::new(HostnameMetaPlugin::new(options, outputs)), MetaPluginType::Hostname => Box::new(HostnameMetaPlugin::new(options, outputs)),
MetaPluginType::Command => { MetaPluginType::Exec => {
// For command type, we need to parse the command from options // For exec type, we need to parse the command from options
let mut program_name = String::new(); let mut program_name = String::new();
let mut args = Vec::new(); let mut args = Vec::new();
let mut meta_name = MetaPluginType::Command.to_string(); let mut meta_name = MetaPluginType::Exec.to_string();
let mut split_whitespace = true; let mut split_whitespace = true;
if let Some(opts) = &options { if let Some(opts) = &options {
@@ -321,12 +321,12 @@ pub fn get_meta_plugin(
} }
} }
Box::new(MetaPluginCommand::new(&program_name, Box::new(MetaPluginExec::new(&program_name,
args.iter().map(|s| s.as_str()).collect(), args.iter().map(|s| s.as_str()).collect(),
meta_name, meta_name,
split_whitespace, split_whitespace,
options, options,
outputs)) outputs))
} }
} }
} }