Skip to content

Commit f26c887

Browse files
Update to clap 4.0.9 (#344)
This migrates everything from structopt and clap 3.* to 4.0.9, while preserving the (sub)command syntax of all the binaries in all the crates in this repo.
1 parent 96b4e3f commit f26c887

18 files changed

Lines changed: 80 additions & 131 deletions

File tree

Cargo.lock

Lines changed: 15 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ version = "0.2.0"
2020
anyhow = "1.0.65"
2121
bitflags = "1.3.2"
2222
heck = "0.3"
23-
structopt = { version = "0.3", default-features = false }
2423
pulldown-cmark = { version = "0.8", default-features = false }
25-
clap = { version = "3.2.22", features = ["derive"] }
24+
clap = { version = "4.0.9", features = ["derive"] }
2625

2726
wasmtime = "1.0"
2827
wasmtime-wasi = "1.0"
@@ -50,12 +49,12 @@ test = false
5049

5150
[dependencies]
5251
anyhow = { workspace = true }
53-
structopt = { version = "0.3", default-features = false }
52+
clap = { workspace = true }
5453
wit-bindgen-core = { path = 'crates/bindgen-core' }
55-
wit-bindgen-gen-guest-rust = { path = 'crates/gen-guest-rust', features = ['structopt'] }
56-
wit-bindgen-gen-host-wasmtime-rust = { path = 'crates/gen-host-wasmtime-rust', features = ['structopt'] }
57-
wit-bindgen-gen-host-wasmtime-py = { path = 'crates/gen-host-wasmtime-py', features = ['structopt'] }
58-
wit-bindgen-gen-host-js = { path = 'crates/gen-host-js', features = ['structopt'] }
59-
wit-bindgen-gen-guest-c = { path = 'crates/gen-guest-c', features = ['structopt'] }
60-
wit-bindgen-gen-markdown = { path = 'crates/gen-markdown', features = ['structopt'] }
61-
wit-bindgen-gen-guest-teavm-java = { path = 'crates/gen-guest-teavm-java', features = ['structopt'] }
54+
wit-bindgen-gen-guest-rust = { path = 'crates/gen-guest-rust', features = ['clap'] }
55+
wit-bindgen-gen-host-wasmtime-rust = { path = 'crates/gen-host-wasmtime-rust', features = ['clap'] }
56+
wit-bindgen-gen-host-wasmtime-py = { path = 'crates/gen-host-wasmtime-py', features = ['clap'] }
57+
wit-bindgen-gen-host-js = { path = 'crates/gen-host-js', features = ['clap'] }
58+
wit-bindgen-gen-guest-c = { path = 'crates/gen-guest-c', features = ['clap'] }
59+
wit-bindgen-gen-markdown = { path = 'crates/gen-markdown', features = ['clap'] }
60+
wit-bindgen-gen-guest-teavm-java = { path = 'crates/gen-guest-teavm-java', features = ['clap'] }

crates/gen-guest-c/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test = false
1111
[dependencies]
1212
wit-bindgen-core = { workspace = true }
1313
heck = { workspace = true }
14-
structopt = { workspace = true, optional = true }
14+
clap = { workspace = true, optional = true }
1515

1616
[dev-dependencies]
1717
test-helpers = { path = '../test-helpers', features = ['guest-c'] }

crates/gen-guest-c/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct Func {
4141
}
4242

4343
#[derive(Default, Debug, Clone)]
44-
#[cfg_attr(feature = "structopt", derive(structopt::StructOpt))]
44+
#[cfg_attr(feature = "clap", derive(clap::Args))]
4545
pub struct Opts {
4646
// ...
4747
}

crates/gen-guest-rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
wit-bindgen-core = { workspace = true }
1313
wit-bindgen-gen-rust-lib = { workspace = true }
1414
heck = { workspace = true }
15-
structopt = { workspace = true, optional = true }
15+
clap = { workspace = true, optional = true }
1616

1717
[dev-dependencies]
1818
wit-bindgen-guest-rust = { path = '../guest-rust' }

crates/gen-guest-rust/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ pub struct RustWasm {
2424
}
2525

2626
#[derive(Default, Debug, Clone)]
27-
#[cfg_attr(feature = "structopt", derive(structopt::StructOpt))]
27+
#[cfg_attr(feature = "clap", derive(clap::Args))]
2828
pub struct Opts {
2929
/// Whether or not `rustfmt` is executed to format generated code.
30-
#[cfg_attr(feature = "structopt", structopt(long))]
30+
#[cfg_attr(feature = "clap", arg(long))]
3131
pub rustfmt: bool,
3232

3333
/// Adds the wit module name into import binding names when enabled.
34-
#[cfg_attr(feature = "structopt", structopt(long))]
34+
#[cfg_attr(feature = "clap", arg(long))]
3535
pub multi_module: bool,
3636

3737
/// Whether or not the bindings assume interface values are always
3838
/// well-formed or whether checks are performed.
39-
#[cfg_attr(feature = "structopt", structopt(long))]
39+
#[cfg_attr(feature = "clap", arg(long))]
4040
pub unchecked: bool,
4141

4242
/// A prefix to prepend to all exported symbols. Note that this is only
4343
/// intended for testing because it breaks the general form of the ABI.
44-
#[cfg_attr(feature = "structopt", structopt(skip))]
44+
#[cfg_attr(feature = "clap", arg(skip))]
4545
pub symbol_namespace: String,
4646

4747
/// If true, the code generation is intended for standalone crates.
@@ -51,7 +51,7 @@ pub struct Opts {
5151
/// For exported interfaces, an `export!` macro is also generated
5252
/// that can be used to export an implementation from a different
5353
/// crate.
54-
#[cfg_attr(feature = "structopt", structopt(skip))]
54+
#[cfg_attr(feature = "clap", arg(skip))]
5555
pub standalone: bool,
5656
}
5757

crates/gen-guest-teavm-java/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition.workspace = true
66
[dependencies]
77
wit-bindgen-core = { workspace = true }
88
heck = { version = "0.4", features = [ "unicode" ] }
9-
structopt = { workspace = true, optional = true }
9+
clap = { workspace = true, optional = true }
1010

1111
[dev-dependencies]
1212
test-helpers = { path = '../test-helpers', default-features = false, features = ['guest-teavm-java'] }

crates/gen-guest-teavm-java/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pub struct TeaVmJava {
2424
}
2525

2626
#[derive(Default, Debug, Clone)]
27-
#[cfg_attr(feature = "structopt", derive(structopt::StructOpt))]
27+
#[cfg_attr(feature = "clap", derive(clap::Args))]
2828
pub struct Opts {
2929
/// Whether or not to generate a stub class for exported functions
30-
#[cfg_attr(feature = "structopt", structopt(long))]
30+
#[cfg_attr(feature = "clap", arg(long))]
3131
pub generate_stub: bool,
3232
}
3333

crates/gen-host-js/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test = false
1111
[dependencies]
1212
wit-bindgen-core = { workspace = true }
1313
heck = { workspace = true }
14-
structopt = { workspace = true, optional = true }
14+
clap = { workspace = true, optional = true }
1515

1616
[dev-dependencies]
1717
test-helpers = { path = '../test-helpers', features = ['host-js'] }

crates/gen-host-js/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ struct Exports {
3737
}
3838

3939
#[derive(Default, Debug, Clone)]
40-
#[cfg_attr(feature = "structopt", derive(structopt::StructOpt))]
40+
#[cfg_attr(feature = "clap", derive(clap::Args))]
4141
pub struct Opts {
42-
#[cfg_attr(feature = "structopt", structopt(long = "no-typescript"))]
42+
#[cfg_attr(feature = "clap", arg(long = "no-typescript"))]
4343
pub no_typescript: bool,
4444
}
4545

0 commit comments

Comments
 (0)