create folder method

This commit is contained in:
grimhilt 2023-06-08 18:34:51 +02:00
parent 1b63c86c1a
commit 26153219b2
3 changed files with 41 additions and 4 deletions

View File

@ -1,7 +1,16 @@
use crate::commands::{status, config};
pub fn push() {
dbg!(status::get_diff());
let (staged_obj, new_obj, del_obj) = status::get_diff();
dbg!(config::get("remote"));
dbg!(status::get_diff());
let remote = match config::get("remote") {
Some(r) => r,
None => {
eprintln!("fatal: no remote set in configuration");
std::process::exit(1);
}
};
let (staged_obj, new_obj, del_obj) = status::get_diff();
}

View File

@ -0,0 +1,28 @@
use crate::services::api::{ApiBuilder, ApiError};
use reqwest::{Method, IntoUrl, Response, Error};
pub struct CreateFolder {
api_builder: ApiBuilder,
}
impl CreateFolder {
pub fn new<U: IntoUrl>(url: U) -> Self {
ListFolders {
api_builder: ApiBuilder::new()
.set_request(Method::from_bytes(b"MKCOL").unwrap(), url),
}
}
pub async fn send(&mut self) -> Result<Response, Error> {
self.api_builder.send().await
}
pub async fn send_with_err(mut self) -> Result<(), ApiError> {
let res = self.send().await.map_err(ApiError::RequestError)?;
if res.status().is_success() {
Ok()
} else {
Err(ApiError::IncorrectRequest(res))
}
}
}

View File

@ -14,7 +14,7 @@ pub fn current() -> Option<PathBuf> {
} else {
let current_dir = env::current_dir().ok()?;
let abs = current_dir.join(tmp);
let canonicalized_path = canonicalize(abs).ok()?;
let canonicalized_path = canonicalize(abs).ok()?;
Some(canonicalized_path)
}