improve status and minor fixes

This commit is contained in:
grimhilt
2023-07-24 00:48:22 +02:00
parent 4e20ec94f9
commit 2775c77c55
4 changed files with 26 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
use crate::commands::{clone::get_url_props, config};
#[derive(Debug)]
pub struct ApiProps {
pub host: String, // nextcloud.example.com
@@ -15,6 +17,23 @@ impl Clone for ApiProps {
}
}
pub fn get_api_props() -> ApiProps {
let remote = match config::get("remote") {
Some(r) => r,
None => {
eprintln!("fatal: unable to find a remote");
std::process::exit(1);
}
};
let (host, username, root) = get_url_props(&remote);
ApiProps {
host,
username: username.unwrap().to_owned(),
root: root.to_owned(),
}
}
pub fn get_relative_s(p: String, api_props: &ApiProps) -> String {
let mut final_p = p.clone();
final_p = final_p.strip_prefix("/remote.php/dav/files/").unwrap().to_string();