Skip to content

Commit

Permalink
added replace when downloading option
Browse files Browse the repository at this point in the history
  • Loading branch information
Waradu committed Oct 20, 2024
1 parent a452ff1 commit 6fb6657
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 8 deletions.
64 changes: 61 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
path = "src/main.rs"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ struct Args {
download: Option<String>,

#[arg(
short,
long,
value_name = "PATH",
help = "Set the path to download the file to."
)]
path: Option<String>,

#[arg(
long,
value_name = "REPLACE",
help = "Replace file when downloading if it already exists.",
)]
replace: bool,
}

#[tokio::main]
Expand Down Expand Up @@ -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),
}
Expand Down

0 comments on commit 6fb6657

Please sign in to comment.