Fix clippy warnings
This commit is contained in:
parent
9b88539c50
commit
3355763992
@ -55,7 +55,7 @@ fn run_inner(app: &mut App) -> Result<CommandResult> {
|
|||||||
let mut stdin = child.stdin.take().context("Could not take stdin")?;
|
let mut stdin = child.stdin.take().context("Could not take stdin")?;
|
||||||
let text_orig_clone = app.text_orig.clone();
|
let text_orig_clone = app.text_orig.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let _ = stdin.write_all(text_orig_clone.as_bytes());
|
let _result = stdin.write_all(text_orig_clone.as_bytes());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Collect the output
|
// Collect the output
|
||||||
|
35
src/main.rs
35
src/main.rs
@ -63,7 +63,7 @@ impl App {
|
|||||||
let cmdline_position = 0;
|
let cmdline_position = 0;
|
||||||
|
|
||||||
match template {
|
match template {
|
||||||
Template::Generic(_) => Self {
|
Template::Awk | Template::Generic(_) => Self {
|
||||||
cmdline: String::new(),
|
cmdline: String::new(),
|
||||||
cmdline_position,
|
cmdline_position,
|
||||||
text_orig,
|
text_orig,
|
||||||
@ -82,8 +82,8 @@ impl App {
|
|||||||
hidden_options: vec!["-C"],
|
hidden_options: vec!["-C"],
|
||||||
},
|
},
|
||||||
Template::Grep | Template::Rg => Self {
|
Template::Grep | Template::Rg => Self {
|
||||||
cmdline: String::from("'^'"),
|
cmdline: String::from("''"),
|
||||||
cmdline_position: 2,
|
cmdline_position: 1,
|
||||||
text_orig,
|
text_orig,
|
||||||
command_result: CommandResult::default(),
|
command_result: CommandResult::default(),
|
||||||
autorun: true,
|
autorun: true,
|
||||||
@ -99,15 +99,6 @@ impl App {
|
|||||||
command,
|
command,
|
||||||
hidden_options: vec![],
|
hidden_options: vec![],
|
||||||
},
|
},
|
||||||
Template::Awk => Self {
|
|
||||||
cmdline: String::new(),
|
|
||||||
cmdline_position,
|
|
||||||
text_orig,
|
|
||||||
command_result: CommandResult::default(),
|
|
||||||
autorun: true,
|
|
||||||
command,
|
|
||||||
hidden_options: vec![],
|
|
||||||
},
|
|
||||||
Template::Perl => Self {
|
Template::Perl => Self {
|
||||||
cmdline: String::from("-p -e 's///'"),
|
cmdline: String::from("-p -e 's///'"),
|
||||||
cmdline_position: 10_u16,
|
cmdline_position: 10_u16,
|
||||||
@ -132,7 +123,8 @@ pub enum Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Template {
|
impl Template {
|
||||||
pub fn from(s: String) -> Self {
|
#[must_use]
|
||||||
|
pub fn from(s: &str) -> Self {
|
||||||
match s.to_lowercase().trim() {
|
match s.to_lowercase().trim() {
|
||||||
"jq" => Self::Jq,
|
"jq" => Self::Jq,
|
||||||
"grep" => Self::Grep,
|
"grep" => Self::Grep,
|
||||||
@ -144,15 +136,16 @@ impl Template {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn command(&self) -> String {
|
pub fn command(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Template::Generic(c) => c.to_string(),
|
Self::Generic(c) => c.to_string(),
|
||||||
Template::Jq => String::from("jq"),
|
Self::Jq => String::from("jq"),
|
||||||
Template::Grep => String::from("grep"),
|
Self::Grep => String::from("grep"),
|
||||||
Template::Rg => String::from("rg"),
|
Self::Rg => String::from("rg"),
|
||||||
Template::Sed => String::from("sed"),
|
Self::Sed => String::from("sed"),
|
||||||
Template::Awk => String::from("awk"),
|
Self::Awk => String::from("awk"),
|
||||||
Template::Perl => String::from("perl"),
|
Self::Perl => String::from("perl"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,7 +178,7 @@ fn main() -> Result<()> {
|
|||||||
let text_orig = io::read_to_string(io::stdin())?;
|
let text_orig = io::read_to_string(io::stdin())?;
|
||||||
|
|
||||||
// Run the actual application
|
// Run the actual application
|
||||||
let app = App::from_template(text_orig, &Template::from(arg));
|
let app = App::from_template(text_orig, &Template::from(&arg));
|
||||||
let res = run_app(&mut terminal, app);
|
let res = run_app(&mut terminal, app);
|
||||||
|
|
||||||
// Restore terminal
|
// Restore terminal
|
||||||
|
Loading…
Reference in New Issue
Block a user