start clone get info folder
This commit is contained in:
parent
0817e01bdf
commit
f398347856
@ -2,3 +2,4 @@ pub mod init;
|
||||
pub mod status;
|
||||
pub mod add;
|
||||
pub mod reset;
|
||||
pub mod clone;
|
||||
|
28
src/commands/clone.rs
Normal file
28
src/commands/clone.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use clap::Values;
|
||||
use std::fs::{self, DirBuilder};
|
||||
use std::path::Path;
|
||||
use crate::services::list_folders::ListFolders;
|
||||
use std::error::Error;
|
||||
|
||||
pub fn clone(remote: Values<'_>) {
|
||||
let url = remote.clone().next().unwrap();
|
||||
let path = Path::new(url);
|
||||
|
||||
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
call(url).await
|
||||
});
|
||||
//DirBuilder::new()
|
||||
// .create(path.parent());
|
||||
}
|
||||
|
||||
pub async fn call(url: &str) -> Result<String, Box<dyn Error>> {
|
||||
let response = ListFolders::new(url).send().await?;
|
||||
if response.status().is_success() {
|
||||
let body = response.text().await?;
|
||||
println!("Response body: {}", body);
|
||||
} else {
|
||||
println!("Request failed with status code: {}", response.status());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
15
src/main.rs
15
src/main.rs
@ -9,6 +9,7 @@
|
||||
use clap::{App, Arg, SubCommand};
|
||||
mod commands;
|
||||
mod utils;
|
||||
mod services;
|
||||
fn main() {
|
||||
let matches = App::new("NextSync")
|
||||
.version("1.0")
|
||||
@ -17,6 +18,15 @@ fn main() {
|
||||
.subcommand(SubCommand::with_name("init"))
|
||||
.subcommand(SubCommand::with_name("status"))
|
||||
.subcommand(SubCommand::with_name("reset"))
|
||||
.subcommand(
|
||||
SubCommand::with_name("clone")
|
||||
.arg(
|
||||
Arg::with_name("remote")
|
||||
.required(true)
|
||||
.takes_value(true)
|
||||
.value_name("REMOTE")
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("add")
|
||||
.arg(
|
||||
@ -40,7 +50,12 @@ fn main() {
|
||||
}
|
||||
} else if let Some(_) = matches.subcommand_matches("reset") {
|
||||
commands::reset::reset();
|
||||
} else if let Some(matches) = matches.subcommand_matches("clone") {
|
||||
if let Some(remote) = matches.values_of("remote") {
|
||||
commands::clone::clone(remote);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
|
2
src/services.rs
Normal file
2
src/services.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod api;
|
||||
pub mod list_folders;
|
Loading…
Reference in New Issue
Block a user