fix: resolve compilation errors and warnings
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
@@ -3,7 +3,7 @@ use std::io;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::{Display, EnumString, EnumIter};
|
||||
use strum::{Display, EnumString, EnumIter};
|
||||
|
||||
use log::*;
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ impl FilterPlugin for SkipBytesFilter {
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails.
|
||||
fn filter(&mut self, reader: &mut dyn Read, writer: &mut dyn Write) -> Result<()> {
|
||||
fn filter(&mut self, reader: Box<&mut dyn Read>, writer: Box<&mut dyn Write>) -> Result<()> {
|
||||
// Skip bytes in chunks
|
||||
if self.remaining > 0 {
|
||||
let mut buffer = vec![0; PIPESIZE];
|
||||
while self.remaining > 0 {
|
||||
let to_read = std::cmp::min(self.remaining, PIPESIZE);
|
||||
let bytes_read = reader.read(&mut buffer[..to_read])?;
|
||||
let bytes_read = reader.as_mut().read(&mut buffer[..to_read])?;
|
||||
if bytes_read == 0 {
|
||||
break;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ impl FilterPlugin for SkipBytesFilter {
|
||||
}
|
||||
|
||||
// Copy the remaining data using io::copy for efficiency
|
||||
std::io::copy(reader, writer)?;
|
||||
std::io::copy(reader.as_mut(), writer.as_mut())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -107,14 +107,14 @@ impl FilterPlugin for SkipLinesFilter {
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails.
|
||||
fn filter(&mut self, reader: &mut dyn Read, writer: &mut dyn Write) -> Result<()> {
|
||||
let mut buf_reader = std::io::BufReader::new(reader);
|
||||
fn filter(&mut self, reader: Box<&mut dyn Read>, writer: Box<&mut dyn Write>) -> Result<()> {
|
||||
let mut buf_reader = std::io::BufReader::new(reader.as_mut());
|
||||
for line in buf_reader.by_ref().lines() {
|
||||
let line = line?;
|
||||
if self.remaining > 0 {
|
||||
self.remaining -= 1;
|
||||
} else {
|
||||
writeln!(writer, "{}", line)?;
|
||||
writeln!(writer.as_mut(), "{}", line)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -32,9 +32,9 @@ impl FilterPlugin for StripAnsiFilter {
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails.
|
||||
fn filter(&mut self, reader: &mut dyn Read, writer: &mut dyn Write) -> Result<()> {
|
||||
let mut ansi_writer = Writer::new(writer);
|
||||
std::io::copy(reader, &mut ansi_writer)?;
|
||||
fn filter(&mut self, reader: Box<&mut dyn Read>, writer: Box<&mut dyn Write>) -> Result<()> {
|
||||
let mut ansi_writer = Writer::new(writer.as_mut());
|
||||
std::io::copy(reader.as_mut(), &mut ansi_writer)?;
|
||||
ansi_writer.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ impl FilterPlugin for TailBytesFilter {
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails.
|
||||
fn filter(&mut self, reader: &mut dyn Read, writer: &mut dyn Write) -> Result<()> {
|
||||
fn filter(&mut self, reader: Box<&mut dyn Read>, writer: Box<&mut dyn Write>) -> Result<()> {
|
||||
let mut temp_buffer = vec![0; PIPESIZE];
|
||||
loop {
|
||||
let bytes_read = reader.read(&mut temp_buffer)?;
|
||||
let bytes_read = reader.as_mut().read(&mut temp_buffer)?;
|
||||
if bytes_read == 0 {
|
||||
break;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ impl FilterPlugin for TailBytesFilter {
|
||||
|
||||
// Write the buffered data at the end
|
||||
let result: Vec<u8> = self.buffer.iter().cloned().collect();
|
||||
writer.write_all(&result)?;
|
||||
writer.as_mut().write_all(&result)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ impl FilterPlugin for TailLinesFilter {
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails.
|
||||
fn filter(&mut self, reader: &mut dyn Read, writer: &mut dyn Write) -> Result<()> {
|
||||
let mut buf_reader = std::io::BufReader::new(reader);
|
||||
fn filter(&mut self, reader: Box<&mut dyn Read>, writer: Box<&mut dyn Write>) -> Result<()> {
|
||||
let mut buf_reader = std::io::BufReader::new(reader.as_mut());
|
||||
for line in buf_reader.by_ref().lines() {
|
||||
let line = line?;
|
||||
if self.lines.len() == self.count {
|
||||
@@ -129,7 +129,7 @@ impl FilterPlugin for TailLinesFilter {
|
||||
|
||||
// Write the buffered lines
|
||||
for line in &self.lines {
|
||||
writeln!(writer, "{}", line)?;
|
||||
writeln!(writer.as_mut(), "{}", line)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -50,10 +50,8 @@ use filter_plugin::{
|
||||
head, tail, skip, grep, strip_ansi
|
||||
};
|
||||
|
||||
// Import all meta plugins to ensure they register themselves
|
||||
#[allow(unused_imports)]
|
||||
use crate::meta_plugin::{
|
||||
cwd, text, user, shell, shell_pid, keep_pid, digest,
|
||||
cwd, user, shell, shell_pid, keep_pid, digest,
|
||||
read_time, read_rate, hostname, exec, env
|
||||
};
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ fn register_magic_plugin() {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "magic"))]
|
||||
use crate::meta_plugin::{register_meta_plugin, MetaPluginType};
|
||||
use crate::meta_plugin::register_meta_plugin;
|
||||
#[cfg(not(feature = "magic"))]
|
||||
#[ctor::ctor]
|
||||
fn register_fallback_magic_plugin() {
|
||||
|
||||
@@ -92,7 +92,6 @@ struct MetaPluginConfig {
|
||||
/// ```
|
||||
pub fn mode_generate_config(_cmd: &mut Command, _settings: &crate::config::Settings) -> Result<()> {
|
||||
// Create instances of each meta plugin to get their default options and outputs
|
||||
let text_plugin = crate::meta_plugin::text::TextMetaPlugin::new(None, None);
|
||||
let cwd_plugin = crate::meta_plugin::cwd::CwdMetaPlugin::new(None, None);
|
||||
let digest_plugin = crate::meta_plugin::digest::DigestMetaPlugin::new(None, None);
|
||||
let hostname_plugin = crate::meta_plugin::hostname::HostnameMetaPlugin::new(None, None);
|
||||
@@ -122,12 +121,6 @@ struct MetaPluginConfig {
|
||||
align: ColumnAlignment::Right,
|
||||
max_len: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "meta:text_line_count".to_string(),
|
||||
label: Some("Lines".to_string()),
|
||||
align: ColumnAlignment::Right,
|
||||
max_len: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "tags".to_string(),
|
||||
label: Some("Tags".to_string()),
|
||||
@@ -154,11 +147,6 @@ struct MetaPluginConfig {
|
||||
}),
|
||||
compression_plugin: None,
|
||||
meta_plugins: Some(vec![
|
||||
MetaPluginConfig {
|
||||
name: "text".to_string(),
|
||||
options: text_plugin.options().clone(),
|
||||
outputs: convert_outputs_to_string_map(text_plugin.outputs()),
|
||||
},
|
||||
MetaPluginConfig {
|
||||
name: "cwd".to_string(),
|
||||
options: cwd_plugin.options().clone(),
|
||||
|
||||
Reference in New Issue
Block a user