Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary custom clap value parser #147

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
}