Merge branch 'master' into master

This commit is contained in:
PandaDEV 2024-10-20 22:14:06 +10:00 committed by GitHub
commit ec765d6387
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 4 deletions

View file

@ -1,3 +1,5 @@
use std::{io::Write, time::Instant};
use clap::{CommandFactory, Parser};
use kdam::{tqdm, BarExt, Column, RichProgress, Spinner, term::Colorizer};
use streamshare::{delete, upload};
@ -122,3 +124,19 @@ fn parse_delete_param(param: &str) -> Option<(&str, &str)> {
None
}
}
fn readable(bytes: u64) -> String {
const KB: f64 = 1024.0;
const MB: f64 = KB * 1024.0;
const GB: f64 = MB * 1024.0;
if bytes as f64 >= GB {
format!("{:.2}gb", bytes as f64 / GB)
} else if bytes as f64 >= MB {
format!("{:.2}mb", bytes as f64 / MB)
} else if bytes as f64 >= KB {
format!("{:.2}kb", bytes as f64 / KB)
} else {
format!("{}b", bytes)
}
}