From 6fb66573325766797f2673661c7ccd79ed6ff283 Mon Sep 17 00:00:00 2001 From: Waradu Date: Sun, 20 Oct 2024 21:17:30 +0200 Subject: [PATCH] added replace when downloading option --- Cargo.lock | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 6 ++--- README.md | 1 + src/main.rs | 10 +++++++-- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 94a33a1..a2aba7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,6 +257,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "encode_unicode" version = "0.3.6" @@ -670,6 +691,16 @@ version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -801,6 +832,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "parking_lot" version = "0.12.3" @@ -962,6 +999,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + [[package]] name = "reqwest" version = "0.12.8" @@ -1189,6 +1237,15 @@ dependencies = [ "digest", ] +[[package]] +name = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "dirs", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1237,14 +1294,15 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "streamshare" -version = "4.1.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1960eb9ada032cacbd7b75b1255468a007459729009b76e508579bd49d97171" +checksum = "b3738f5ec13f0df9b7b1f21701dde6b1edf0b6684a82e58a4fd61936377403ef" dependencies = [ "futures", "reqwest", "serde", "serde_json", + "shellexpand", "tokio", "tokio-tungstenite", ] @@ -1362,7 +1420,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "to-streamshare" -version = "0.6.0" +version = "0.7.0" dependencies = [ "clap", "console", diff --git a/Cargo.toml b/Cargo.toml index 391189d..12d22df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "to-streamshare" -version = "0.6.0" +version = "0.7.0" edition = "2021" description = "Upload to streamshare (to-ss > toss) from the terminal" license = "MIT" @@ -14,9 +14,9 @@ keywords = ["streamshare", "file-sharing", "upload"] clap = { version = "4.5.20", features = ["derive"] } console = "0.15.8" kdam = { version = "0.5.2", features = ["rich", "spinner"] } -streamshare = "4.1" +streamshare = "5" tokio = { version = "1.40.0", features = ["full"] } [[bin]] name = "toss" -path = "src/main.rs" \ No newline at end of file +path = "src/main.rs" diff --git a/README.md b/README.md index 731465f..2e49d0f 100644 --- a/README.md +++ b/README.md @@ -27,4 +27,5 @@ toss --delete "file_identifier/deletion_token" ```bash toss --download "file_identifier" toss --download "file_identifier" --path "" # uses current path as default +toss --download "file_identifier" --replace # replace if file already exist ``` \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 0de59a7..d1924e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,12 +46,18 @@ struct Args { download: Option, #[arg( - short, long, value_name = "PATH", help = "Set the path to download the file to." )] path: Option, + + #[arg( + long, + value_name = "REPLACE", + help = "Replace file when downloading if it already exists.", + )] + replace: bool, } #[tokio::main] @@ -83,7 +89,7 @@ async fn main() -> std::io::Result<()> { None => "".to_string() }; - match client.download(download.as_str(), path.as_str()).await { + match client.download(download.as_str(), path.as_str(), args.replace).await { Ok(_) => println!("File downloaded successfully"), Err(e) => eprintln!("Error downloaded file: {}", e), }