create folder method
This commit is contained in:
parent
1b63c86c1a
commit
26153219b2
@ -1,7 +1,16 @@
|
|||||||
use crate::commands::{status, config};
|
use crate::commands::{status, config};
|
||||||
|
|
||||||
pub fn push() {
|
pub fn push() {
|
||||||
dbg!(status::get_diff());
|
dbg!(status::get_diff());
|
||||||
let (staged_obj, new_obj, del_obj) = status::get_diff();
|
|
||||||
dbg!(config::get("remote"));
|
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();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
28
src/services/create_folder.rs
Normal file
28
src/services/create_folder.rs
Normal 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ pub fn current() -> Option<PathBuf> {
|
|||||||
} else {
|
} else {
|
||||||
let current_dir = env::current_dir().ok()?;
|
let current_dir = env::current_dir().ok()?;
|
||||||
let abs = current_dir.join(tmp);
|
let abs = current_dir.join(tmp);
|
||||||
let canonicalized_path = canonicalize(abs).ok()?;
|
let canonicalized_path = canonicalize(abs).ok()?;
|
||||||
Some(canonicalized_path)
|
Some(canonicalized_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user