From cbefeb603e97ae71fcb8a4dadc4ac1f6eb79b30e Mon Sep 17 00:00:00 2001 From: Lucas Trzesniewski Date: Sun, 12 Jan 2025 22:10:40 +0100 Subject: [PATCH] fix: fix clippy warnings --- crates/atuin-daemon/src/server.rs | 1 + crates/atuin/src/command/client/init.rs | 9 ++---- .../src/command/client/init/powershell.rs | 32 +++++-------------- .../src/command/client/search/interactive.rs | 8 +++-- 4 files changed, 17 insertions(+), 33 deletions(-) diff --git a/crates/atuin-daemon/src/server.rs b/crates/atuin-daemon/src/server.rs index c9f97a65c55..eaf9938605a 100644 --- a/crates/atuin-daemon/src/server.rs +++ b/crates/atuin-daemon/src/server.rs @@ -4,6 +4,7 @@ use atuin_client::encryption; use atuin_client::history::store::HistoryStore; use atuin_client::record::sqlite_store::SqliteStore; use atuin_client::settings::Settings; +#[cfg(unix)] use std::path::PathBuf; use std::sync::Arc; use time::OffsetDateTime; diff --git a/crates/atuin/src/command/client/init.rs b/crates/atuin/src/command/client/init.rs index b4f1cc03daa..926474aec74 100644 --- a/crates/atuin/src/command/client/init.rs +++ b/crates/atuin/src/command/client/init.rs @@ -26,6 +26,7 @@ pub struct Cmd { #[derive(Clone, Copy, ValueEnum, Debug)] #[value(rename_all = "lower")] +#[allow(clippy::enum_variant_names, clippy::doc_markdown)] pub enum Shell { /// Zsh setup Zsh, @@ -161,13 +162,7 @@ $env.config = ( .await?; } Shell::PowerShell => { - powershell::init( - alias_store, - var_store, - self.disable_up_arrow, - self.disable_ctrl_r, - ) - .await?; + powershell::init_static(self.disable_up_arrow, self.disable_ctrl_r); } } diff --git a/crates/atuin/src/command/client/init/powershell.rs b/crates/atuin/src/command/client/init/powershell.rs index f87a75a00b0..1185ec6ff27 100644 --- a/crates/atuin/src/command/client/init/powershell.rs +++ b/crates/atuin/src/command/client/init/powershell.rs @@ -1,6 +1,3 @@ -use atuin_dotfiles::store::{var::VarStore, AliasStore}; -use eyre::Result; - pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool) { let base = include_str!("../../../shell/atuin.ps1"); @@ -10,31 +7,18 @@ pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool) { (!disable_ctrl_r, !disable_up_arrow) }; - fn bool(value: bool) -> &'static str { - if value { - "$true" - } else { - "$false" - } - } - println!("{base}"); println!( "Enable-AtuinSearchKeys -CtrlR {} -UpArrow {}", - bool(bind_ctrl_r), - bool(bind_up_arrow) + ps_bool(bind_ctrl_r), + ps_bool(bind_up_arrow) ); } -pub async fn init( - _aliases: AliasStore, - _vars: VarStore, - disable_up_arrow: bool, - disable_ctrl_r: bool, -) -> Result<()> { - init_static(disable_up_arrow, disable_ctrl_r); - - // dotfiles are not supported yet - - Ok(()) +fn ps_bool(value: bool) -> &'static str { + if value { + "$true" + } else { + "$false" + } } diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index 10660804f07..d6ee793cfa0 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -33,8 +33,7 @@ use ratatui::{ cursor::SetCursorStyle, event::{ self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, - KeyboardEnhancementFlags, MouseEvent, PopKeyboardEnhancementFlags, - PushKeyboardEnhancementFlags, + MouseEvent, }, execute, terminal, }, @@ -46,6 +45,11 @@ use ratatui::{ Frame, Terminal, TerminalOptions, Viewport, }; +#[cfg(not(target_os = "windows"))] +use ratatui::crossterm::event::{ + KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags, +}; + const TAB_TITLES: [&str; 2] = ["Search", "Inspect"]; pub enum InputAction {