Skip to content

Commit

Permalink
Update clap deprecated api
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Aug 10, 2023
1 parent 04a9794 commit b6bf2c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::str;
use std::time::Duration;

#[derive(Parser, Debug)]
#[clap(
#[command(
name = "mini-redis-cli",
version,
author,
Expand All @@ -18,18 +18,18 @@ 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,
}

#[derive(Subcommand, Debug)]
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.
Expand All @@ -43,19 +43,19 @@ 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.
Publish {
/// Name of channel
channel: String,

#[clap(value_parser = bytes_from_str)]
#[arg(value_parser = bytes_from_str)]
/// Message to publish
message: Bytes,
},
Expand Down
4 changes: 2 additions & 2 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand Down

0 comments on commit b6bf2c8

Please sign in to comment.