mirror of
https://github.com/Waradu/to-streamshare.git
synced 2025-04-22 04:14:06 +02:00
Merge branch 'master' into master
This commit is contained in:
commit
ec765d6387
3 changed files with 22 additions and 4 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1337,7 +1337,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "to-streamshare"
|
name = "to-streamshare"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"kdam",
|
"kdam",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "to-streamshare"
|
name = "to-streamshare"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Upload to streamshare (to-ss > toss) from the terminal"
|
description = "Upload to streamshare (to-ss > toss) from the terminal"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{io::Write, time::Instant};
|
||||||
|
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
use kdam::{tqdm, BarExt, Column, RichProgress, Spinner, term::Colorizer};
|
use kdam::{tqdm, BarExt, Column, RichProgress, Spinner, term::Colorizer};
|
||||||
use streamshare::{delete, upload};
|
use streamshare::{delete, upload};
|
||||||
|
@ -122,3 +124,19 @@ fn parse_delete_param(param: &str) -> Option<(&str, &str)> {
|
||||||
None
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue