diff options
author | Daniel Melchor <dmh672@gmail.com> | 2023-03-26 19:05:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-26 19:05:31 -0400 |
commit | e97bef2cd2a0cf23e21c524297537c2c41a0aff5 (patch) | |
tree | 6c692c4f528e4ad6e452725bef7236c284ee93b0 | |
parent | c072e8c30663c2132ca09d9ce968d628c2566592 (diff) | |
parent | a771b9e3837137f3033e1b3810bf7a74d9506109 (diff) |
Merge pull request #4 from danimelchor/bug/open_url_fails
Fixed opening link error when url empty
-rw-r--r-- | src/main.rs | 8 | ||||
-rw-r--r-- | src/ui/all_tasks_page.rs | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 6412ee9..75ef93f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,18 @@ use anyhow::Result; use todui::configuration::get_configuration; use todui::{app::App, cli, ui}; -fn main() -> Result<()> { +fn main() { // Check args, if none, run ui, else run cli let settings = get_configuration(); let app = App::new(settings); - if std::env::args().len() > 1 { + let res = if std::env::args().len() > 1 { cli::start_cli(app) } else { ui::start_ui(app) + }; + + if let Err(e) = res { + eprintln!("{}", e); } } diff --git a/src/ui/all_tasks_page.rs b/src/ui/all_tasks_page.rs index b357dba..3b06fab 100644 --- a/src/ui/all_tasks_page.rs +++ b/src/ui/all_tasks_page.rs @@ -3,6 +3,7 @@ use crate::repeat::Repeat; use crate::task::Task; use crate::ui::Page; use crate::utils; +use anyhow::Result; use chrono::{DateTime, Local, TimeZone}; use itertools::Itertools; use std::cell::RefCell; @@ -269,7 +270,7 @@ impl AllTasksPage { utils::date_to_display_str(date, &self.app.borrow().settings) } - pub fn open_selected_link(&self) { + pub fn open_selected_link(&self) -> Result<()> { if let Some(task_id) = self.current_id { let url = self .app @@ -279,8 +280,12 @@ impl AllTasksPage { .url .clone() .unwrap_or_default(); - open::that(url).unwrap(); + + if !url.is_empty() { + open::that(url)?; + } } + Ok(()) } pub fn get_primary_color(&self) -> Color { |