aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorlukeflo2025-02-21 21:55:17 +0100
committerlukeflo2025-02-21 21:55:17 +0100
commitc34412d9e3725bed48af925646110f2ca34b1bd4 (patch)
treee7f48bb25a605aeccf0c31ed310f1c7a1ae9e067 /src/app.rs
parentddb6326c1896b82b759d930fb08ea46a820e275a (diff)
downloadbibiman-c34412d9e3725bed48af925646110f2ca34b1bd4.tar.gz
bibiman-c34412d9e3725bed48af925646110f2ca34b1bd4.zip
implement working config file construct, error handling should be improved
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/app.rs b/src/app.rs
index b3778af..7869304 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -24,7 +24,6 @@ use crate::tui::commands::InputCmdAction;
use crate::tui::popup::PopupKind;
use crate::tui::{self, Tui};
use crate::{bibiman::Bibiman, tui::commands::CmdAction};
-use core::panic;
use std::ffi::OsStr;
use std::path::PathBuf;
use std::process::{Command, Stdio};
@@ -60,14 +59,14 @@ impl App {
})
}
- pub async fn run(&mut self, args: &mut CLIArgs, cfg: &BibiConfig) -> Result<()> {
+ pub async fn run(&mut self, cfg: &BibiConfig) -> Result<()> {
let mut tui = tui::Tui::new()?;
tui.enter()?;
// Start the main loop.
while self.running {
// Render the user interface.
- tui.draw(self, args)?;
+ tui.draw(self, cfg)?;
// Handle events.
match tui.next().await? {
Event::Tick => self.tick(),
@@ -86,10 +85,10 @@ impl App {
} else {
CmdAction::from(key_event)
};
- self.run_command(command, args, cfg, &mut tui)?
+ self.run_command(command, cfg, &mut tui)?
}
Event::Mouse(mouse_event) => {
- self.run_command(CmdAction::from(mouse_event), args, cfg, &mut tui)?
+ self.run_command(CmdAction::from(mouse_event), cfg, &mut tui)?
}
Event::Resize(_, _) => {}
@@ -111,13 +110,7 @@ impl App {
self.running = false;
}
- pub fn run_command(
- &mut self,
- cmd: CmdAction,
- args: &mut CLIArgs,
- cfg: &BibiConfig,
- tui: &mut Tui,
- ) -> Result<()> {
+ pub fn run_command(&mut self, cmd: CmdAction, cfg: &BibiConfig, tui: &mut Tui) -> Result<()> {
match cmd {
CmdAction::Input(cmd) => match cmd {
InputCmdAction::Nothing => {}
@@ -149,7 +142,7 @@ impl App {
|| doi.starts_with("http://doi.org")
|| doi.starts_with("http://dx.doi.org")
{
- self.bibiman.handle_new_entry_submission(args, doi);
+ self.bibiman.handle_new_entry_submission(doi);
} else {
self.bibiman.popup_area.popup_message(
"No valid DOI pattern: ",
@@ -278,7 +271,7 @@ impl App {
self.bibiman.open_connected_res(cfg)?;
} else if let Some(PopupKind::AppendToFile) = self.bibiman.popup_area.popup_kind
{
- self.bibiman.append_entry_to_file(args)?
+ self.bibiman.append_entry_to_file()?
}
}
}
@@ -310,7 +303,7 @@ impl App {
}
CmdAction::EditFile => {
if let CurrentArea::EntryArea = self.bibiman.current_area {
- self.bibiman.run_editor(cfg, args, tui)?;
+ self.bibiman.run_editor(cfg, tui)?;
}
}
CmdAction::Open => {
@@ -419,15 +412,6 @@ pub fn expand_home(path: &PathBuf) -> PathBuf {
}
}
-fn select_opener() -> String {
- match std::env::consts::OS {
- "linux" => String::from("xdg-open"),
- "macos" => String::from("open"),
- "windows" => String::from("start"),
- _ => panic!("Couldn't detect OS for setting correct opener"),
- }
-}
-
#[cfg(test)]
mod test {
use super::*;