Skip to content

Commit 7ffaaaf

Browse files
authored
feat: migrate to latest clap (#24)
migrate to latest clap
1 parent 044090b commit 7ffaaaf

File tree

4 files changed

+32
-161
lines changed

4 files changed

+32
-161
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ name = "pbcli"
2121
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2222

2323
[dependencies]
24-
clap = { version = "3.0.0-rc.1", features = ["derive"] }
24+
clap = { version = "4.5.29", features = ["derive"] }
2525
reqwest = { version = "0.12", features = ["blocking", "json"] }
2626
serde = { version = "1.0.130", features = ["derive"] }
2727
serde_json = "1.0.69"

src/opts.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ Project home page: https://github.com/Mydayyy/pbcli";
1010

1111
#[derive(Debug, Parser, Clone)]
1212
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
13-
#[clap(setting = clap::AppSettings::AllArgsOverrideSelf, version = env ! ("CARGO_PKG_VERSION"), author = "Mydayyy <dev@mydayyy.eu>", about = ABOUT
14-
)]
15-
#[clap(term_width(if let Some((terminal_size::Width(w), _)) = terminal_size::terminal_size() { w as usize } else { 120 }
16-
))]
13+
#[clap( version = env ! ("CARGO_PKG_VERSION"), author = "Mydayyy <dev@mydayyy.eu>", about = ABOUT)]
14+
#[clap(term_width(if let Some((terminal_size::Width(w), _)) = terminal_size::terminal_size() { w as usize } else { 120 }))]
1715
#[clap(rename_all = "kebab-case")]
16+
#[command(args_override_self = true)]
1817
pub struct Opts {
19-
#[clap(required_unless_present("host"), parse(try_from_str))]
18+
#[clap(required_unless_present("host"))]
2019
pub url: Option<Url>,
2120

2221
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
23-
#[clap(long, parse(try_from_str))]
22+
#[clap(long)]
2423
pub host: Option<Url>,
2524

26-
#[clap(long, arg_enum, default_value = "plaintext")]
25+
#[clap(long, value_enum, default_value = "plaintext")]
2726
pub format: PasteFormat,
2827

2928
#[cfg_attr(feature = "uniffi", uniffi(default = "1week"))]
3029
#[clap(long, default_value = "1week")]
3130
pub expire: String,
3231

3332
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
34-
#[clap(long, parse(try_from_str = parse_size))]
33+
#[clap(long)]
34+
#[arg(value_parser = |x: &str| parse_size(x))] // closure: https://github.com/clap-rs/clap/issues/4939
3535
#[clap(help(
3636
"Prompt if the paste exceeds the given size. Fail in non-interactive environments."
3737
))]
@@ -63,23 +63,23 @@ pub struct Opts {
6363
pub comment_to: Option<String>,
6464

6565
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
66-
#[clap(long, parse(from_os_str), value_name = "FILE")]
66+
#[clap(long, value_name = "FILE")]
6767
pub download: Option<std::path::PathBuf>,
6868
#[cfg_attr(feature = "uniffi", uniffi(default = false))]
6969
#[clap(long)]
7070
#[clap(help("overwrite the file given with --download if it already exists"))]
7171
pub overwrite: bool,
7272

7373
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
74-
#[clap(long, parse(from_os_str), value_name = "FILE")]
74+
#[clap(long, value_name = "FILE")]
7575
pub upload: Option<std::path::PathBuf>,
7676

7777
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
7878
#[clap(long)]
7979
pub password: Option<String>,
8080

8181
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
82-
#[clap(long, requires_all(& ["oidc-client-id", "oidc-username", "oidc-password"]))]
82+
#[clap(long, requires_all(& ["oidc_client_id", "oidc_username", "oidc_password"]))]
8383
#[clap(help("oidc token endpoint from which to obtain an access token"))]
8484
pub oidc_token_url: Option<String>,
8585

src/privatebin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum CompressionType {
2020
Zlib,
2121
}
2222

23-
#[derive(Default, clap::ArgEnum, Deserialize, Debug, Serialize, Clone, Copy)]
23+
#[derive(Default, clap::ValueEnum, Deserialize, Debug, Serialize, Clone, Copy)]
2424
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
2525
pub enum PasteFormat {
2626
#[default]

0 commit comments

Comments
 (0)