From b63a4894a1d13cf2c48b175b709f9eb5f8c3efca Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 2 Aug 2024 16:12:26 +0900 Subject: [PATCH] Update clap deprecated api (#132) --- src/bin/cli.rs | 14 +++++++------- src/bin/server.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 2515684..43b7b90 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -8,7 +8,7 @@ use std::str; use std::time::Duration; #[derive(Parser, Debug)] -#[clap( +#[command( name = "mini-redis-cli", version, author, @@ -18,10 +18,10 @@ struct Cli { #[clap(subcommand)] command: Command, - #[clap(name = "hostname", long, default_value = "127.0.0.1")] + #[arg(id = "hostname", long, default_value = "127.0.0.1")] host: String, - #[clap(long, default_value_t = DEFAULT_PORT)] + #[arg(long, default_value_t = DEFAULT_PORT)] port: u16, } @@ -29,7 +29,7 @@ struct Cli { enum Command { Ping { /// Message to ping - #[clap(value_parser = bytes_from_str)] + #[arg(value_parser = bytes_from_str)] msg: Option, }, /// Get the value of key. @@ -43,11 +43,11 @@ enum Command { key: String, /// Value to set. - #[clap(value_parser = bytes_from_str)] + #[arg(value_parser = bytes_from_str)] value: Bytes, /// Expire the value after specified amount of time - #[clap(value_parser = duration_from_ms_str)] + #[arg(value_parser = duration_from_ms_str)] expires: Option, }, /// Publisher to send a message to a specific channel. @@ -55,7 +55,7 @@ enum Command { /// Name of channel channel: String, - #[clap(value_parser = bytes_from_str)] + #[arg(value_parser = bytes_from_str)] /// Message to publish message: Bytes, }, diff --git a/src/bin/server.rs b/src/bin/server.rs index 4eef2b5..898b0a6 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -44,9 +44,9 @@ pub async fn main() -> mini_redis::Result<()> { } #[derive(Parser, Debug)] -#[clap(name = "mini-redis-server", version, author, about = "A Redis server")] +#[command(name = "mini-redis-server", version, author, about = "A Redis server")] struct Cli { - #[clap(long)] + #[arg(long)] port: Option, }