refactor: rename program plugin to command
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub mod program;
|
pub mod command;
|
||||||
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::program::MetaPluginProgram;
|
use crate::meta_plugin::command::MetaPluginCommand;
|
||||||
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;
|
||||||
@@ -132,7 +132,7 @@ pub enum MetaPluginType {
|
|||||||
ReadTime,
|
ReadTime,
|
||||||
ReadRate,
|
ReadRate,
|
||||||
Hostname,
|
Hostname,
|
||||||
Program,
|
Command,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Central function to handle metadata output with name mapping
|
/// Central function to handle metadata output with name mapping
|
||||||
@@ -290,11 +290,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::Program => {
|
MetaPluginType::Command => {
|
||||||
// For program type, we need to parse the command from options
|
// For command 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 = "program".to_string();
|
let mut meta_name = "command".to_string();
|
||||||
let mut split_whitespace = true;
|
let mut split_whitespace = true;
|
||||||
|
|
||||||
if let Some(opts) = &options {
|
if let Some(opts) = &options {
|
||||||
@@ -320,7 +320,7 @@ pub fn get_meta_plugin(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box::new(MetaPluginProgram::new(&program_name,
|
Box::new(MetaPluginCommand::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,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use which::which;
|
|||||||
|
|
||||||
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse};
|
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse};
|
||||||
|
|
||||||
pub struct MetaPluginProgram {
|
pub struct MetaPluginCommand {
|
||||||
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 MetaPluginProgram {
|
|||||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
options: std::collections::HashMap<String, serde_yaml::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for MetaPluginProgram {
|
impl std::fmt::Debug for MetaPluginCommand {
|
||||||
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("MetaPluginProgram")
|
f.debug_struct("MetaPluginCommand")
|
||||||
.field("program", &self.program)
|
.field("program", &self.program)
|
||||||
.field("args", &self.args)
|
.field("args", &self.args)
|
||||||
.field("supported", &self.supported)
|
.field("supported", &self.supported)
|
||||||
@@ -34,7 +34,7 @@ impl std::fmt::Debug for MetaPluginProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetaPluginProgram {
|
impl MetaPluginCommand {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
program: &str,
|
program: &str,
|
||||||
args: Vec<&str>,
|
args: Vec<&str>,
|
||||||
@@ -42,7 +42,7 @@ impl MetaPluginProgram {
|
|||||||
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>>,
|
||||||
) -> MetaPluginProgram {
|
) -> MetaPluginCommand {
|
||||||
let program_path = which(program);
|
let program_path = which(program);
|
||||||
let supported = program_path.is_ok();
|
let supported = program_path.is_ok();
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ impl MetaPluginProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaPluginProgram {
|
MetaPluginCommand {
|
||||||
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 MetaPluginProgram {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetaPlugin for MetaPluginProgram {
|
impl MetaPlugin for MetaPluginCommand {
|
||||||
fn is_supported(&self) -> bool {
|
fn is_supported(&self) -> bool {
|
||||||
self.supported
|
self.supported
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user