From dea6108b8ec5f9196d8698fe2821d1d4c291cce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:55:30 +0000 Subject: [PATCH] wip: main business logic --- src/appstate.rs | 7 +++---- src/main.rs | 7 ++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/appstate.rs b/src/appstate.rs index f40d63a..ba51491 100644 --- a/src/appstate.rs +++ b/src/appstate.rs @@ -69,17 +69,16 @@ impl AppState { .ok() } - pub fn from_args(args: &Cli, http: &ureq::Agent) -> Option { + pub fn from_args(args: &Cli, http: &ureq::Agent) -> Result { let file_name = Self::cache_file(args); let alias = args.get_alias(); let share = Share::create(http, &alias, args.get_share_request()) - .inspect_err(|e| debug!("could not create Share: {e}")) - .ok()?; + .map_err(|e| format!("could not create share: {e}"))?; let files: VecDeque<_> = args.files.clone().into_iter().map(FileState::C).collect(); - Some(Self { + Ok(Self { file_name, alias, share, diff --git a/src/main.rs b/src/main.rs index 858065f..6e79ec2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,10 +41,11 @@ fn main() { state }) - .or_else(|| AppState::from_args(&args, &agent)) .unwrap_or_else(|| { - error!("could not create new state from cli arguments: {args:?}"); - exit(1); + AppState::from_args(&args, &agent).unwrap_or_else(|e| { + error!("could not create new state: {e}"); + exit(1); + }) }); info!("continuing with state: {state:?}");