From 20926514d2d2558963b2d8af694180a7a16ea7ba Mon Sep 17 00:00:00 2001 From: grimhilt Date: Sun, 25 Jun 2023 17:45:51 +0200 Subject: [PATCH] allow url format without username --- src/commands/clone.rs | 11 +++++++---- src/commands/push.rs | 3 ++- src/commands/status.rs | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/commands/clone.rs b/src/commands/clone.rs index e22f58f..56d8df6 100644 --- a/src/commands/clone.rs +++ b/src/commands/clone.rs @@ -1,3 +1,5 @@ +use std::io; +use std::io::prelude::*; use std::fs::DirBuilder; use std::path::{Path, PathBuf}; use clap::Values; @@ -16,15 +18,16 @@ pub fn clone(remote: Values<'_>) { let url = remote.clone().next().unwrap(); let (host, tmp_user, dist_path_str) = get_url_props(url); let username = match tmp_user { - Some(u) => u, + Some(u) => u.to_string(), None => { - eprintln!("No username found"); - todo!(); + println!("Please enter the username of the webdav instance: "); + let stdin = io::stdin(); + stdin.lock().lines().next().unwrap().unwrap() } }; let api_props = ApiProps { host: host.clone(), - username: username.to_string(), + username: username, root: dist_path_str.to_string(), }; diff --git a/src/commands/push.rs b/src/commands/push.rs index dfb57b3..dc16610 100644 --- a/src/commands/push.rs +++ b/src/commands/push.rs @@ -36,6 +36,7 @@ pub fn push() { for obj in staged_objs { if obj.otype == String::from("tree") { + dbg!(("folder", obj.clone())); let push_factory = PushFactory.new_dir(obj.clone()); let res = match push_factory.can_push(&mut whitelist) { PushState::Valid => push_factory.push(), @@ -44,8 +45,8 @@ pub fn push() { _ => todo!(), }; - dbg!("should push folder"); } else { + dbg!(("file", obj.clone())); let push_factory = PushFactory.new(obj.clone()); match push_factory.can_push(&mut whitelist) { PushState::Valid => push_factory.push(), diff --git a/src/commands/status.rs b/src/commands/status.rs index 58a1a35..debf84c 100644 --- a/src/commands/status.rs +++ b/src/commands/status.rs @@ -26,6 +26,7 @@ pub enum State { } // todo: relative path, filename, get modified +// todo: not catch added empty folder pub fn status() { let (mut new_objs, mut del_objs) = get_diff(); dbg!(get_diff()); @@ -51,7 +52,7 @@ pub fn get_all_staged() -> Vec { // todo opti return folder let (mut new_objs, mut del_objs) = get_diff(); let mut renamed_objs = get_renamed(&mut new_objs, &mut del_objs); - // get copy, modified + // todo get copy, modified let mut objs = new_objs; objs.append(&mut del_objs); objs.append(&mut renamed_objs);