From e354e97facdf61abb20a06f5bae2bac5e86c2d62 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sat, 23 Nov 2024 00:49:00 +0100 Subject: implement needed dep injection of cli args --- src/app.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index 7b6a30d..cd27996 100644 --- a/src/app.rs +++ b/src/app.rs @@ -44,7 +44,7 @@ pub struct App { impl App { // Constructs a new instance of [`App`]. - pub fn new(args: CLIArgs) -> Result { + pub fn new(args: &CLIArgs) -> Result { // Self::default() let running = true; let input = Input::default(); @@ -57,14 +57,14 @@ impl App { }) } - pub async fn run(&mut self) -> Result<()> { + pub async fn run(&mut self, args: &CLIArgs) -> Result<()> { let mut tui = tui::Tui::new()?; tui.enter()?; // Start the main loop. while self.running { // Render the user interface. - tui.draw(self)?; + tui.draw(self, args)?; // Handle events. match tui.next().await? { Event::Tick => self.tick(), @@ -83,10 +83,10 @@ impl App { } else { CmdAction::from(key_event) }; - self.run_command(command, &mut tui)? + self.run_command(command, args, &mut tui)? } Event::Mouse(mouse_event) => { - self.run_command(CmdAction::from(mouse_event), &mut tui)? + self.run_command(CmdAction::from(mouse_event), args, &mut tui)? } Event::Resize(_, _) => {} @@ -108,7 +108,7 @@ impl App { self.running = false; } - pub fn run_command(&mut self, cmd: CmdAction, tui: &mut Tui) -> Result<()> { + pub fn run_command(&mut self, cmd: CmdAction, args: &CLIArgs, tui: &mut Tui) -> Result<()> { match cmd { CmdAction::Input(cmd) => match cmd { InputCmdAction::Nothing => {} @@ -278,7 +278,7 @@ impl App { } CmdAction::EditFile => { if let CurrentArea::EntryArea = self.bibiman.current_area { - self.bibiman.run_editor(tui)?; + self.bibiman.run_editor(args, tui)?; } } CmdAction::Open => { -- cgit v1.2.3