wip: main business logic
This commit is contained in:
parent
e7f0fc5a38
commit
dea6108b8e
2 changed files with 7 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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:?}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue