aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorlukeflo2024-11-23 00:49:00 +0100
committerlukeflo2024-11-23 00:49:00 +0100
commite354e97facdf61abb20a06f5bae2bac5e86c2d62 (patch)
treece3f15e72289f25f8c4a06fb5f5b891d3a643f60 /src/app.rs
parent53679da34cd7fe84aaac2a15f936e1450de7c125 (diff)
downloadbibiman-e354e97facdf61abb20a06f5bae2bac5e86c2d62.tar.gz
bibiman-e354e97facdf61abb20a06f5bae2bac5e86c2d62.zip
implement needed dep injection of cli args
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs14
1 files changed, 7 insertions, 7 deletions
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<Self> {
+ pub fn new(args: &CLIArgs) -> Result<Self> {
// 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 => {