wip: main business logic

This commit is contained in:
Jörn-Michael Miehe 2025-06-05 01:55:30 +00:00
parent e7f0fc5a38
commit dea6108b8e
2 changed files with 7 additions and 7 deletions

View file

@ -69,17 +69,16 @@ impl AppState {
.ok() .ok()
} }
pub fn from_args(args: &Cli, http: &ureq::Agent) -> Option<Self> { pub fn from_args(args: &Cli, http: &ureq::Agent) -> Result<Self, String> {
let file_name = Self::cache_file(args); let file_name = Self::cache_file(args);
let alias = args.get_alias(); let alias = args.get_alias();
let share = Share::create(http, &alias, args.get_share_request()) let share = Share::create(http, &alias, args.get_share_request())
.inspect_err(|e| debug!("could not create Share: {e}")) .map_err(|e| format!("could not create share: {e}"))?;
.ok()?;
let files: VecDeque<_> = args.files.clone().into_iter().map(FileState::C).collect(); let files: VecDeque<_> = args.files.clone().into_iter().map(FileState::C).collect();
Some(Self { Ok(Self {
file_name, file_name,
alias, alias,
share, share,

View file

@ -41,10 +41,11 @@ fn main() {
state state
}) })
.or_else(|| AppState::from_args(&args, &agent))
.unwrap_or_else(|| { .unwrap_or_else(|| {
error!("could not create new state from cli arguments: {args:?}"); AppState::from_args(&args, &agent).unwrap_or_else(|e| {
exit(1); error!("could not create new state: {e}");
exit(1);
})
}); });
info!("continuing with state: {state:?}"); info!("continuing with state: {state:?}");