diff --git a/src/app/event_handler.rs b/src/app/event_handler.rs index 69260ae..da7129b 100644 --- a/src/app/event_handler.rs +++ b/src/app/event_handler.rs @@ -1,7 +1,8 @@ use std::time::Duration; -use crossterm::event::{self, KeyCode, KeyEvent}; use anyhow::Result; +use crossterm::event::{self, KeyCode, KeyEvent}; + use super::events; pub struct EventHandler; @@ -21,8 +22,7 @@ impl EventHandler { fn handle_keypress(keyevent: KeyEvent) -> Result { match keyevent.code { KeyCode::Char('q') => Ok(events::Event::Exit), - _ => Ok(events::Event::Noop) + _ => Ok(events::Event::Noop), } } } - diff --git a/src/app/events.rs b/src/app/events.rs index a889cc3..c7167d0 100644 --- a/src/app/events.rs +++ b/src/app/events.rs @@ -1,4 +1,4 @@ pub enum Event { Exit, - Noop + Noop, } diff --git a/src/app/mod.rs b/src/app/mod.rs index 92f6736..3a8b102 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1,18 +1,13 @@ mod event_handler; mod events; -mod ui; mod formatter; +mod ui; + +use std::{io, thread, time::Duration}; -use crate::database; -use crate::output; -use crate::params::Params; -use crate::scanner; use anyhow::{anyhow, Result}; use crossterm::{event, execute, terminal}; use event_handler::EventHandler; -use std::io; -use std::thread; -use std::time::Duration; use tui::{ backend::CrosstermBackend, widgets::{Block, Borders, Widget}, @@ -20,19 +15,24 @@ use tui::{ }; use ui::Ui; +use crate::database; +use crate::output; +use crate::params::Params; +use crate::scanner; + pub struct App; impl App { pub fn init(app_args: &Params) -> Result<()> { // let mut term = Self::init_terminal()?; - let connection = database::get_connection(&app_args)?; - let duplicates = scanner::duplicates(&app_args, &connection)?; + let connection = database::get_connection(app_args)?; + let duplicates = scanner::duplicates(app_args, &connection)?; // Self::init_render_loop(&mut term)?; // Self::cleanup(&mut term)?; - output::print(duplicates, &app_args); /* TODO: APP TUI INIT FUNCTION */ + output::print(duplicates, app_args); /* TODO: APP TUI INIT FUNCTION */ Ok(()) } @@ -56,6 +56,8 @@ impl App { } fn init_render_loop(term: &mut Terminal>) -> Result<()> { + // this could be simplified with a `while Self::render_cycle(term).is_ok() {}` in the current state, but maybe + // it's good to keep it to handle errors in the future loop { match Self::render_cycle(term) { Ok(_) => continue, diff --git a/src/app/ui.rs b/src/app/ui.rs index 19413a4..9b8c63b 100644 --- a/src/app/ui.rs +++ b/src/app/ui.rs @@ -1,5 +1,6 @@ -use anyhow::Result; use std::io; + +use anyhow::Result; use tui::{ backend::{Backend, CrosstermBackend}, layout::{Constraint, Direction, Layout, Rect}, diff --git a/src/main.rs b/src/main.rs index 7cb8c91..21ac960 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,13 @@ -mod params; +#![allow(unused)] // TODO: remove this once TUI is implemented +mod app; mod database; mod output; +mod params; mod scanner; -mod app; use anyhow::Result; -use clap::Parser; use app::App; +use clap::Parser; #[tokio::main] async fn main() -> Result<()> {