pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/google/webbundle/commit/088059f2b1963d78d1e1cf911729206577fa5de5

e157469407.css" /> Drop structopt and use clap v4 · google/webbundle@088059f · GitHub
Skip to content

Commit 088059f

Browse files
committed
Drop structopt and use clap v4
1 parent 56d122f commit 088059f

File tree

6 files changed

+30
-36
lines changed

6 files changed

+30
-36
lines changed

webbundle-bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ version = "0.1.0"
1111
[dependencies]
1212
anyhow = "1.0.57"
1313
askama = "0.11.1"
14+
clap = { version = "4", features = ["derive"] }
1415
env_logger = "0.9.0"
1516
log = "0.4.17"
16-
structopt = "0.3.26"
1717
webbundle = { path = "../webbundle", version = "^0.3.2" }

webbundle-bench/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ use std::path::{Path, PathBuf};
22

33
use anyhow::Result;
44
use askama::Template;
5-
use structopt::StructOpt;
5+
use clap::Parser;
66

7-
#[derive(StructOpt, Debug)]
7+
#[derive(Parser, Debug)]
88
struct Cli {
99
//github.com/ The output directory
10-
#[structopt(short = "o", long = "out", default_value = "out")]
10+
#[arg(short = 'o', long, default_value = "out")]
1111
out: String,
1212
//github.com/ The module tree depth
13-
#[structopt(short = "d", long = "depth", default_value = "4")]
13+
#[arg(short = 'd', long, default_value = "4")]
1414
depth: u32,
1515
//github.com/ The module tree width at each level
16-
#[structopt(short = "b", long = "branches", default_value = "4")]
16+
#[arg(short = 'b', long, default_value = "4")]
1717
branches: u32,
1818
}
1919

@@ -243,7 +243,7 @@ struct IndexTemplate {
243243

244244
fn main() -> Result<()> {
245245
env_logger::init();
246-
let args = Cli::from_args();
246+
let args = Cli::parse();
247247
let benchmark = Benchmark::new(&args);
248248
benchmark.build(&args)
249249
}

webbundle-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository = "https://github.com/google/webbundle"
99
version = "0.3.2"
1010

1111
[dependencies]
12-
structopt = "0.3.26"
12+
clap = { version = "4", features = ["derive"] }
1313
env_logger = "0.9.0"
1414
log = "0.4.17"
1515
chrono = "0.4.19"

webbundle-cli/src/main.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,32 @@
1414

1515
use anyhow::{ensure, Context as _};
1616
use chrono::Local;
17+
use clap::Parser;
1718
use serde::Serialize;
1819
use std::fs::File;
1920
use std::io::{BufWriter, Read as _, Write as _};
2021
use std::path::{Component, Path, PathBuf};
21-
use structopt::clap::arg_enum;
22-
use structopt::StructOpt;
2322
use url::Url;
2423
use webbundle::{Bundle, Result, Version};
2524

26-
#[derive(StructOpt)]
25+
#[derive(Parser)]
2726
struct Cli {
28-
#[structopt(subcommand)]
27+
#[clap(subcommand)]
2928
cmd: Command,
3029
}
3130

32-
arg_enum! {
33-
#[allow(non_camel_case_types)]
34-
pub enum Format {
35-
plain,
36-
json,
37-
debug,
38-
}
31+
#[derive(Parser, Clone, clap::ValueEnum)]
32+
enum Format {
33+
Plain,
34+
Json,
35+
Debug,
3936
}
4037

41-
#[derive(StructOpt)]
38+
#[derive(Parser)]
4239
enum Command {
4340
//github.com/ Example: webbundle create example.wbn foo
44-
#[structopt(name = "create")]
4541
Create {
46-
#[structopt(short = "p", long = "primary-url")]
42+
#[arg(short = 'p', long)]
4743
primary_url: Option<String>,
4844
//github.com/ File name
4945
file: String,
@@ -52,14 +48,12 @@ enum Command {
5248
// TODO: Support version
5349
},
5450
//github.com/ List the contents briefly
55-
#[structopt(name = "list")]
5651
List {
5752
file: String,
58-
#[structopt(long = "format", possible_values(&Format::variants()))]
53+
#[arg(long, value_enum)]
5954
format: Option<Format>,
6055
},
6156
//github.com/ Extract the contents
62-
#[structopt(name = "extract")]
6357
Extract { file: String },
6458
}
6559

@@ -82,9 +76,9 @@ fn env_logger_init() {
8276

8377
fn list(bundle: &Bundle, format: Option<Format>) {
8478
match format {
85-
None | Some(Format::plain) => list_plain(bundle),
86-
Some(Format::json) => list_json(bundle),
87-
Some(Format::debug) => list_debug(bundle),
79+
None | Some(Format::Plain) => list_plain(bundle),
80+
Some(Format::Json) => list_json(bundle),
81+
Some(Format::Debug) => list_debug(bundle),
8882
}
8983
}
9084

@@ -270,7 +264,7 @@ fn extract(bundle: &Bundle) -> Result<()> {
270264
#[tokio::main]
271265
async fn main() -> Result<()> {
272266
env_logger_init();
273-
let args = Cli::from_args();
267+
let args = Cli::parse();
274268
match args.cmd {
275269
Command::Create {
276270
primary_url,

webbundle-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ version = "0.3.0"
1212
anyhow = "1.0.52"
1313
axum = "0.4.4"
1414
axum-extra = "0.1.1"
15+
clap = { version = "4", features = ["derive"] }
1516
headers = "0.3.5"
1617
http = "0.2.6"
1718
mime = "0.3.16"
1819
serde = { version = "1.0.133", features = ["derive"] }
19-
structopt = "0.3.26"
2020
tokio = { version = "1.15.0", features = ["macros"] }
2121
tracing = "0.1.29"
2222
tower-http = { version = "0.2.0", features = ["fs", "trace"] }

webbundle-server/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ use axum::{
55
Router,
66
};
77
use axum_extra::middleware::{self, Next};
8+
use clap::Parser;
89
use headers::{ContentLength, HeaderMapExt as _};
910
use http::{header, HeaderValue, Request, Response, StatusCode};
1011
use std::fmt::Write as _;
11-
use structopt::StructOpt;
1212
use tower::ServiceBuilder;
1313
use tower_http::{services::ServeDir, trace::TraceLayer};
1414
use webbundle::{Bundle, Version};
1515

16-
#[derive(StructOpt, Debug)]
16+
#[derive(Parser, Debug)]
1717
struct Cli {
1818
// TODO: Support https.
19-
// #[structopt(long = "https")]
19+
// #[arg]
2020
// https: bool,
21-
#[structopt(short = "p", long = "port", default_value = "8000")]
21+
#[arg(short, long, default_value = "8000")]
2222
port: u16,
23-
#[structopt(long = "bind-all")]
23+
#[arg(long)]
2424
//github.com/ Bind all interfaces (default: only localhost - "127.0.0.1"),
2525
bind_all: bool,
2626
}
@@ -32,7 +32,7 @@ async fn main() {
3232
std::env::set_var("RUST_LOG", "my_http_server=debug,tower_http=debug")
3333
}
3434
tracing_subscriber::fmt::init();
35-
let args = Cli::from_args();
35+
let args = Cli::parse();
3636

3737
let app = Router::new()
3838
.nest("/wbn", get(webbundle_serve))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy