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()
}
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 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,

View file

@ -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:?}");