Resolve clippy warnings (#187)
* refactor: nest or patterns * refactor: fix clippy lint names * refactor: remove unnecessary wraps * style: apply cargo fmt
This commit is contained in:
parent
2024884f49
commit
446ffb88c7
4 changed files with 11 additions and 12 deletions
|
@ -60,7 +60,7 @@ pub enum Cmd {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::clippy::cast_sign_loss)]
|
#[allow(clippy::cast_sign_loss)]
|
||||||
pub fn print_list(h: &[History], human: bool, cmd_only: bool) {
|
pub fn print_list(h: &[History], human: bool, cmd_only: bool) {
|
||||||
let mut writer = TabWriter::new(std::io::stdout()).padding(2);
|
let mut writer = TabWriter::new(std::io::stdout()).padding(2);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use eyre::Result;
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
|
@ -20,11 +19,10 @@ fn init_bash() {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cmd {
|
impl Cmd {
|
||||||
pub fn run(&self) -> Result<()> {
|
pub fn run(&self) {
|
||||||
match self {
|
match self {
|
||||||
Self::Zsh => init_zsh(),
|
Self::Zsh => init_zsh(),
|
||||||
Self::Bash => init_bash(),
|
Self::Bash => init_bash(),
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,10 @@ impl AtuinCmd {
|
||||||
Self::Import(import) => import.run(&mut db).await,
|
Self::Import(import) => import.run(&mut db).await,
|
||||||
Self::Server(server) => server.run(&server_settings).await,
|
Self::Server(server) => server.run(&server_settings).await,
|
||||||
Self::Stats(stats) => stats.run(&mut db, &client_settings).await,
|
Self::Stats(stats) => stats.run(&mut db, &client_settings).await,
|
||||||
Self::Init(init) => init.run(),
|
Self::Init(init) => {
|
||||||
|
init.run();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Self::Search {
|
Self::Search {
|
||||||
cwd,
|
cwd,
|
||||||
exit,
|
exit,
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct State {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
#[allow(clippy::clippy::cast_sign_loss)]
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn durations(&self) -> Vec<(String, String)> {
|
fn durations(&self) -> Vec<(String, String)> {
|
||||||
self.results
|
self.results
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -179,9 +179,7 @@ async fn key_handler(
|
||||||
app: &mut State,
|
app: &mut State,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
match input {
|
match input {
|
||||||
Key::Esc | Key::Ctrl('c') | Key::Ctrl('d') | Key::Ctrl('g') => {
|
Key::Esc | Key::Ctrl('c' | 'd' | 'g') => return Some(String::from("")),
|
||||||
return Some(String::from(""))
|
|
||||||
}
|
|
||||||
Key::Char('\n') => {
|
Key::Char('\n') => {
|
||||||
let i = app.results_state.selected().unwrap_or(0);
|
let i = app.results_state.selected().unwrap_or(0);
|
||||||
|
|
||||||
|
@ -241,7 +239,7 @@ async fn key_handler(
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
fn draw<T: Backend>(f: &mut Frame<'_, T>, history_count: i64, app: &mut State) {
|
fn draw<T: Backend>(f: &mut Frame<'_, T>, history_count: i64, app: &mut State) {
|
||||||
let chunks = Layout::default()
|
let chunks = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
|
@ -312,7 +310,7 @@ fn draw<T: Backend>(f: &mut Frame<'_, T>, history_count: i64, app: &mut State) {
|
||||||
// this is a big blob of horrible! clean it up!
|
// this is a big blob of horrible! clean it up!
|
||||||
// for now, it works. But it'd be great if it were more easily readable, and
|
// for now, it works. But it'd be great if it were more easily readable, and
|
||||||
// modular. I'd like to add some more stats and stuff at some point
|
// modular. I'd like to add some more stats and stuff at some point
|
||||||
#[allow(clippy::clippy::cast_possible_truncation)]
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
async fn select_history(
|
async fn select_history(
|
||||||
query: &[String],
|
query: &[String],
|
||||||
search_mode: SearchMode,
|
search_mode: SearchMode,
|
||||||
|
@ -350,7 +348,7 @@ async fn select_history(
|
||||||
|
|
||||||
// This is supposed to more-or-less mirror the command line version, so ofc
|
// This is supposed to more-or-less mirror the command line version, so ofc
|
||||||
// it is going to have a lot of args
|
// it is going to have a lot of args
|
||||||
#[allow(clippy::clippy::clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn run(
|
pub async fn run(
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
cwd: Option<String>,
|
cwd: Option<String>,
|
||||||
|
|
Loading…
Reference in a new issue