Skip to content

Commit

Permalink
progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodesdev committed May 11, 2024
1 parent 219e7aa commit 441bcfe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fast-scp"
version = "0.1.0"
version = "0.1.1"
description = "A fast and simple scp CLI tool"
license = "MIT"
repository = "https://github.com/dcodesdev/fast-scp"
Expand Down
13 changes: 11 additions & 2 deletions src/scp.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use futures::future::join_all;
use indicatif::ProgressBar;
use indicatif::{ProgressBar, ProgressStyle};
use ssh2::Session;
use std::{
fs::{self, File},
io::{Read, Write},
net::TcpStream,
path::PathBuf,
time::Duration,
};

use crate::{error::ScpError, utils::with_retry};
Expand All @@ -32,6 +33,14 @@ impl Connect {

let files = self.list(from)?;
let pb = ProgressBar::new(files.len() as u64);
pb.set_style(
ProgressStyle::with_template(
"{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len} ({eta})",
)
.unwrap()
.progress_chars("#>-"),
);
pb.enable_steady_tick(Duration::from_millis(100));

let mut handles = Vec::new();
for item in files {
Expand All @@ -53,7 +62,7 @@ impl Connect {
let items = join_all(handles).await;

if items.iter().all(|x| x.is_ok()) {
println!("Done in {:.2?}", start.elapsed());
println!("\nDone in {:.2?}", start.elapsed());
Ok(())
} else {
Err(std::io::Error::new(
Expand Down

0 comments on commit 441bcfe

Please sign in to comment.