Skip to content

Commit

Permalink
publish 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mankong committed Jan 9, 2025
1 parent 68d8f3e commit b81bbed
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
storage/
storage/
*.pkg
24 changes: 16 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
authors = ["Mankong <mankong@mankong.me>"]
authors = ["Mankong <mankong@mankong.me>", "siwilizhao <siwilizhao@gmail.com>"]
categories = ["filesystem", "command-line-interface"]
description = "async download file"
documentation = "https://docs.rs/siwi-download"
Expand All @@ -9,7 +9,7 @@ license = "MIT"
name = "siwi-download"
readme = "README.md"
repository = "https://github.com/rs-videos/siwi-download.git"
version = "0.2.5"
version = "0.3.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[package.metadata.docs.rs]
Expand All @@ -21,13 +21,21 @@ docs = ["unstable"]
unstable = []

[dependencies]
anyhow = "1"
chrono = "0.4"
indicatif = "0.17"
reqwest = {version = "0.12", default-features = false, features = [
anyhow = "^1"
chrono = "^0.4"
indicatif = "^0.17"
reqwest = {version = "^0.12", default-features = false, features = [
"rustls-tls",
"json",
]}
tokio = {version = "1", features = ["fs", "macros", "rt-multi-thread"]}
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing = "^0.1"
tracing-subscriber = "0.3"

[[example]]
name = "cli"
path = "examples/cli.rs"

[[example]]
name = "download"
path = "examples/download.rs"
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@

Siwi Download is a downloader build on tokio and reqwest.

## Install

```sh
cargo install siwi-download
```

## Download file

```sh
siwi-download https://nodejs.org/dist/v22.11.0/node-v22.11.0.pkg
```

## Example

> cargo run --example download
Expand Down
13 changes: 13 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Examples

## cli

```sh
cargo run --example cli url
```

## download

```sh
cargo run --example download
```
29 changes: 29 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#[macro_use]
extern crate tracing;

use siwi_download::download::Download;
use siwi_download::download::DownloadOptions;
use siwi_download::error::AnyResult;
use tracing::Level;
use tracing_subscriber::FmtSubscriber;

#[tokio::main]
async fn main() -> AnyResult<()> {
let subscriber = FmtSubscriber::builder()
.with_max_level(Level::INFO)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");

let args: Vec<String> = std::env::args().collect();
let storage_path = std::env::current_dir()?;
let storage_path = storage_path.to_str().unwrap_or("");

if let Some(url) = args.get(1) {
let mut options = DownloadOptions::default();
options.set_show_progress(true);
let download = Download::new(storage_path);
let report = download.download(url, options).await?;
info!("{:?}", report);
}
Ok(())
}

0 comments on commit b81bbed

Please sign in to comment.