Update clap deprecated api (#132)

This commit is contained in:
tottoto
2024-08-02 16:12:26 +09:00
committed by GitHub
parent c2b18b96d1
commit b63a4894a1
2 changed files with 9 additions and 9 deletions

View File

@@ -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<Bytes>,
},
/// 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<Duration>,
},
/// 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,
},

View File

@@ -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<u16>,
}