Skip to content

Commit

Permalink
Remove unnecessary custom clap value parser (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Aug 3, 2024
1 parent b63a489 commit e186482
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use mini_redis::{clients::Client, DEFAULT_PORT};

use bytes::Bytes;
use clap::{Parser, Subcommand};
use std::convert::Infallible;
use std::num::ParseIntError;
use std::str;
use std::time::Duration;
Expand All @@ -29,7 +28,6 @@ struct Cli {
enum Command {
Ping {
/// Message to ping
#[arg(value_parser = bytes_from_str)]
msg: Option<Bytes>,
},
/// Get the value of key.
Expand All @@ -43,7 +41,6 @@ enum Command {
key: String,

/// Value to set.
#[arg(value_parser = bytes_from_str)]
value: Bytes,

/// Expire the value after specified amount of time
Expand All @@ -55,7 +52,6 @@ enum Command {
/// Name of channel
channel: String,

#[arg(value_parser = bytes_from_str)]
/// Message to publish
message: Bytes,
},
Expand Down Expand Up @@ -153,7 +149,3 @@ fn duration_from_ms_str(src: &str) -> Result<Duration, ParseIntError> {
let ms = src.parse::<u64>()?;
Ok(Duration::from_millis(ms))
}

fn bytes_from_str(src: &str) -> Result<Bytes, Infallible> {
Ok(Bytes::from(src.to_string()))
}

0 comments on commit e186482

Please sign in to comment.