Make the validation especific to str plugin for now.

This commit is contained in:
Andrés N. Robalino 2019-07-28 20:13:06 -05:00
parent d1399c0c0c
commit 87b299739c
2 changed files with 8 additions and 16 deletions

View File

@ -5,14 +5,6 @@ use std::io;
pub trait Plugin { pub trait Plugin {
fn config(&mut self) -> Result<CommandConfig, ShellError>; fn config(&mut self) -> Result<CommandConfig, ShellError>;
#[allow(unused)]
fn is_valid(&self) -> bool {
true
}
#[allow(unused)]
fn log_error(&mut self, message: &str) { }
#[allow(unused)] #[allow(unused)]
fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> { fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> {
Ok(vec![]) Ok(vec![])

View File

@ -21,6 +21,14 @@ impl Str {
} }
} }
fn is_valid(&self) -> bool {
(self.downcase && !self.upcase) || (!self.downcase && self.upcase)
}
fn log_error(&mut self, message: &str) {
self.error = Some(message.to_string());
}
fn to_downcase(&mut self) { fn to_downcase(&mut self) {
self.downcase = true; self.downcase = true;
@ -107,14 +115,6 @@ impl Plugin for Str {
}) })
} }
fn is_valid(&self) -> bool {
(self.downcase && !self.upcase) || (!self.downcase && self.upcase)
}
fn log_error(&mut self, message: &str) {
self.error = Some(message.to_string());
}
fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> { fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> {
if call_info.args.has("downcase") { if call_info.args.has("downcase") {
self.to_downcase(); self.to_downcase();