Skip to content

Commit 3c1bf01

Browse files
committed
Update clap dependency to 4.0
Update the clap dependency to 4.0 to get the latest that there is in terms of argument handling.
1 parent d6062a4 commit 3c1bf01

File tree

10 files changed

+129
-150
lines changed

10 files changed

+129
-150
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Unreleased
88
- Added community maintained Nix flake to the repository
99
- Adjusted program to use Rust Edition 2021
1010
- Updated minimum supported Rust version to `1.56.0`
11-
- Updated argument handling to use `clap` `3.0`
11+
- Updated argument handling to use `clap` `4.0`
1212
- Bumped `anyhow` dependency to `1.0.89`
1313
- Bumped `base32` dependency to `0.5.1`
1414
- Bumped `directories` dependency to `5.0.1`

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Cargo.toml
22

3-
# Copyright (C) 2017-2024 The Nitrocli Developers
3+
# Copyright (C) 2017-2025 The Nitrocli Developers
44
# SPDX-License-Identifier: GPL-3.0-or-later
55

66
[package]
@@ -47,12 +47,12 @@ version = "1.0"
4747
version = "0.5.1"
4848

4949
[dependencies.clap]
50-
version = "3.0"
50+
version = "4.0"
5151
default-features = false
52-
features = ["derive", "std", "unicode"]
52+
features = ["derive", "error-context", "help", "std", "string", "unicode", "usage"]
5353

5454
[dependencies.clap_complete]
55-
version = "3.0"
55+
version = "4.0"
5656
optional = true
5757

5858
[dependencies.directories]

ext/otp_cache.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// otp_cache.rs
22

3-
// Copyright (C) 2020-2024 The Nitrocli Developers
3+
// Copyright (C) 2020-2025 The Nitrocli Developers
44
// SPDX-License-Identifier: GPL-3.0-or-later
55

66
use std::fs;
77
use std::io::Write as _;
88
use std::path;
99

1010
use anyhow::Context as _;
11-
use clap::StructOpt as _;
11+
use clap::Parser as _;
1212

1313
mod ext;
1414

@@ -33,17 +33,17 @@ struct Slot {
3333
/// `--force-update` option is set. The cache includes the Nitrokey's
3434
/// serial number so that it is possible to use it with multiple
3535
/// devices.
36-
#[derive(Debug, clap::StructOpt)]
37-
#[structopt(bin_name = "nitrocli otp-cache")]
36+
#[derive(Debug, clap::Parser)]
37+
#[clap(bin_name = "nitrocli otp-cache")]
3838
struct Args {
3939
/// Always query the slot data even if it is already cached
40-
#[structopt(short, long, global = true)]
40+
#[clap(short, long, global = true)]
4141
force_update: bool,
42-
#[structopt(subcommand)]
42+
#[clap(subcommand)]
4343
cmd: Command,
4444
}
4545

46-
#[derive(Debug, clap::StructOpt)]
46+
#[derive(Debug, clap::Parser)]
4747
enum Command {
4848
/// Generates a one-time password
4949
Get {
@@ -55,12 +55,12 @@ enum Command {
5555
}
5656

5757
fn main() -> anyhow::Result<()> {
58-
let args = Args::from_args();
58+
let args = Args::parse();
5959
let ctx = ext::Context::from_env()?;
6060

6161
let cache = get_cache(&ctx, args.force_update)?;
6262
match &args.cmd {
63-
Command::Get { name } => cmd_get(&ctx, &cache, name)?,
63+
Command::Get { name } => cmd_get(&ctx, &cache, &name)?,
6464
Command::List => cmd_list(&cache),
6565
}
6666
Ok(())

src/arg_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// arg_util.rs
22

3-
// Copyright (C) 2019-2024 The Nitrocli Developers
3+
// Copyright (C) 2019-2025 The Nitrocli Developers
44
// SPDX-License-Identifier: GPL-3.0-or-later
55

66
macro_rules! count {
@@ -22,7 +22,7 @@ macro_rules! Command {
2222
$( $(#[$doc:meta])* $var:ident$(($inner:ty))? => $exec:expr, ) *
2323
] ) => {
2424
$(#[$docs])*
25-
#[derive(Debug, PartialEq, clap::StructOpt)]
25+
#[derive(Debug, PartialEq, clap::Parser)]
2626
pub enum $name {
2727
$(
2828
$(#[$doc])*

0 commit comments

Comments
 (0)