allow url format without username

This commit is contained in:
grimhilt 2023-06-25 17:45:51 +02:00
parent b07e3062b7
commit 20926514d2
3 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,5 @@
use std::io;
use std::io::prelude::*;
use std::fs::DirBuilder; use std::fs::DirBuilder;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use clap::Values; use clap::Values;
@ -16,15 +18,16 @@ pub fn clone(remote: Values<'_>) {
let url = remote.clone().next().unwrap(); let url = remote.clone().next().unwrap();
let (host, tmp_user, dist_path_str) = get_url_props(url); let (host, tmp_user, dist_path_str) = get_url_props(url);
let username = match tmp_user { let username = match tmp_user {
Some(u) => u, Some(u) => u.to_string(),
None => { None => {
eprintln!("No username found"); println!("Please enter the username of the webdav instance: ");
todo!(); let stdin = io::stdin();
stdin.lock().lines().next().unwrap().unwrap()
} }
}; };
let api_props = ApiProps { let api_props = ApiProps {
host: host.clone(), host: host.clone(),
username: username.to_string(), username: username,
root: dist_path_str.to_string(), root: dist_path_str.to_string(),
}; };

View File

@ -36,6 +36,7 @@ pub fn push() {
for obj in staged_objs { for obj in staged_objs {
if obj.otype == String::from("tree") { if obj.otype == String::from("tree") {
dbg!(("folder", obj.clone()));
let push_factory = PushFactory.new_dir(obj.clone()); let push_factory = PushFactory.new_dir(obj.clone());
let res = match push_factory.can_push(&mut whitelist) { let res = match push_factory.can_push(&mut whitelist) {
PushState::Valid => push_factory.push(), PushState::Valid => push_factory.push(),
@ -44,8 +45,8 @@ pub fn push() {
_ => todo!(), _ => todo!(),
}; };
dbg!("should push folder");
} else { } else {
dbg!(("file", obj.clone()));
let push_factory = PushFactory.new(obj.clone()); let push_factory = PushFactory.new(obj.clone());
match push_factory.can_push(&mut whitelist) { match push_factory.can_push(&mut whitelist) {
PushState::Valid => push_factory.push(), PushState::Valid => push_factory.push(),

View File

@ -26,6 +26,7 @@ pub enum State {
} }
// todo: relative path, filename, get modified // todo: relative path, filename, get modified
// todo: not catch added empty folder
pub fn status() { pub fn status() {
let (mut new_objs, mut del_objs) = get_diff(); let (mut new_objs, mut del_objs) = get_diff();
dbg!(get_diff()); dbg!(get_diff());
@ -51,7 +52,7 @@ pub fn get_all_staged() -> Vec<LocalObj> {
// todo opti return folder // todo opti return folder
let (mut new_objs, mut del_objs) = get_diff(); let (mut new_objs, mut del_objs) = get_diff();
let mut renamed_objs = get_renamed(&mut new_objs, &mut del_objs); let mut renamed_objs = get_renamed(&mut new_objs, &mut del_objs);
// get copy, modified // todo get copy, modified
let mut objs = new_objs; let mut objs = new_objs;
objs.append(&mut del_objs); objs.append(&mut del_objs);
objs.append(&mut renamed_objs); objs.append(&mut renamed_objs);