diff --git a/Cargo.lock b/Cargo.lock index a4b1510..4f3362a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,6 +641,7 @@ dependencies = [ "md5", "regex", "reqwest", + "rpassword", "rust-crypto", "textwrap 0.13.4", "tokio", @@ -915,6 +916,27 @@ dependencies = [ "winreg", ] +[[package]] +name = "rpassword" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +dependencies = [ + "libc", + "rtoolbox", + "winapi", +] + +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "rust-crypto" version = "0.2.36" diff --git a/Cargo.toml b/Cargo.toml index f81d6e5..b333907 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ chrono = "0.4.26" indicatif = "0.17.5" md5 = "0.7.0" futures-util = "0.3.28" +rpassword = "7.2" [profile.release] debug = true diff --git a/src/commands/clone.rs b/src/commands/clone.rs index 02b9374..b384948 100644 --- a/src/commands/clone.rs +++ b/src/commands/clone.rs @@ -10,6 +10,7 @@ use crate::utils::path::path_buf_to_string; use crate::utils::remote::{enumerate_remote, EnumerateOptions}; use crate::global::global::{DIR_PATH, set_dir_path}; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::req_props::{ReqProps, ObjProps}; use crate::store::object::{tree, blob::Blob}; use crate::commands::config; diff --git a/src/commands/push/copied.rs b/src/commands/push/copied.rs index 36cdd19..d8ba916 100644 --- a/src/commands/push/copied.rs +++ b/src/commands/push/copied.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; use crate::services::r#copy::Copy; +use crate::services::api_call::ApiCall; use crate::services::req_props::ReqProps; use crate::commands::status::LocalObj; use crate::commands::push::push_factory::{PushState, PushChange, PushFlowState}; @@ -26,10 +27,10 @@ impl PushChange for Copied { fn push(&self) -> io::Result<()> { let obj = &self.obj; let res = Copy::new() - .set_url( + .set_url_copy( &path_buf_to_string(obj.path_from.clone().unwrap()), obj.path.to_str().unwrap()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/push/deleted.rs b/src/commands/push/deleted.rs index 9b44ce0..134fb66 100644 --- a/src/commands/push/deleted.rs +++ b/src/commands/push/deleted.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::delete_path::DeletePath; use crate::store::index; use crate::store::object::blob::Blob; @@ -26,7 +27,7 @@ impl PushChange for Deleted { let obj = &self.obj; let res = DeletePath::new() .set_url(obj.path.to_str().unwrap()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/push/modified.rs b/src/commands/push/modified.rs index e223bda..4119f22 100644 --- a/src/commands/push/modified.rs +++ b/src/commands/push/modified.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::req_props::ReqProps; use crate::services::upload_file::UploadFile; use crate::commands::status::LocalObj; @@ -27,7 +28,7 @@ impl PushChange for Modified { let res = UploadFile::new() .set_url(obj.path.to_str().unwrap()) .set_file(obj.path.clone()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/push/moved.rs b/src/commands/push/moved.rs index 6aacc9a..916ae8d 100644 --- a/src/commands/push/moved.rs +++ b/src/commands/push/moved.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::r#move::Move; use crate::services::req_props::ReqProps; use crate::commands::status::LocalObj; @@ -26,10 +27,10 @@ impl PushChange for Moved { fn push(&self) -> io::Result<()> { let obj = &self.obj; let res = Move::new() - .set_url( + .set_url_move( &path_buf_to_string(obj.path_from.clone().unwrap()), obj.path.to_str().unwrap()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/push/new.rs b/src/commands/push/new.rs index d7ae645..a760f6c 100644 --- a/src/commands/push/new.rs +++ b/src/commands/push/new.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::req_props::ReqProps; use crate::services::upload_file::UploadFile; use crate::store::object::blob::Blob; @@ -27,7 +28,7 @@ impl PushChange for New { let res = UploadFile::new() .set_url(obj.path.to_str().unwrap()) .set_file(obj.path.clone()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/push/new_dir.rs b/src/commands/push/new_dir.rs index 443f66b..5c0f5fe 100644 --- a/src/commands/push/new_dir.rs +++ b/src/commands/push/new_dir.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::req_props::ReqProps; use crate::services::create_folder::CreateFolder; use crate::store::index; @@ -33,7 +34,7 @@ impl PushChange for NewDir { let obj = &self.obj; let res = CreateFolder::new() .set_url(obj.path.to_str().unwrap()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/push/push_factory.rs b/src/commands/push/push_factory.rs index 32cbc9a..98d4d01 100644 --- a/src/commands/push/push_factory.rs +++ b/src/commands/push/push_factory.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use std::io; use crate::commands::status::{State, LocalObj}; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::req_props::ReqProps; use crate::commands::push::new::New; use crate::commands::push::new_dir::NewDir; diff --git a/src/commands/push/rm_dir.rs b/src/commands/push/rm_dir.rs index 429a5e5..f313258 100644 --- a/src/commands/push/rm_dir.rs +++ b/src/commands/push/rm_dir.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::io; use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::delete_path::DeletePath; use crate::store::index; use crate::store::object::tree; @@ -32,7 +33,7 @@ impl PushChange for RmDir { let obj = &self.obj; let res = DeletePath::new() .set_url(obj.path.to_str().unwrap()) - .send_with_err(); + .send(); match res { Err(ApiError::IncorrectRequest(err)) => { diff --git a/src/commands/remote_diff.rs b/src/commands/remote_diff.rs index 5c8cebf..400651a 100644 --- a/src/commands/remote_diff.rs +++ b/src/commands/remote_diff.rs @@ -1,4 +1,5 @@ use crate::services::api::ApiError; +use crate::services::api_call::ApiCall; use crate::services::req_props::{ReqProps, ObjProps}; use crate::store::object::Object; use crate::utils::api::{ApiProps, get_api_props}; diff --git a/src/services.rs b/src/services.rs index e1fbd30..9b9f0af 100644 --- a/src/services.rs +++ b/src/services.rs @@ -7,4 +7,8 @@ pub mod delete_path; pub mod downloader; pub mod r#move; pub mod r#copy; +pub mod login; +pub mod request_manager; +pub mod api_call; +//pub mod auth; //pub mod bulk_upload; diff --git a/src/utils/nextsyncignore.rs b/src/utils/nextsyncignore.rs index 4764b94..256d075 100644 --- a/src/utils/nextsyncignore.rs +++ b/src/utils/nextsyncignore.rs @@ -2,7 +2,6 @@ use std::fs::File; use std::io::{BufReader, BufRead}; use regex::Regex; use crate::utils::path; -use std::io::Cursor; pub fn read_lines() -> Result, ()> { if let Some(path) = path::nextsyncignore() {