add cli for server/client (#4)

This PR adds a CLI to main.rs that allows you to run the redis server and eventually the redis client.
This commit is contained in:
Avery Harnish
2020-03-03 11:15:20 -06:00
committed by GitHub
parent 9852de9924
commit 80511f2cb5
12 changed files with 233 additions and 25 deletions

17
src/bin/server.rs Normal file
View File

@@ -0,0 +1,17 @@
use clap::Clap;
use mini_redis::{server, DEFAULT_PORT};
use std::io;
#[tokio::main]
pub async fn main() -> io::Result<()> {
let cli = Cli::parse();
let port = cli.port.unwrap_or(DEFAULT_PORT.to_string());
server::run(&port).await
}
#[derive(Clap, Debug)]
#[clap(name = "mini-redis-server", version = env!("CARGO_PKG_VERSION"), author = env!("CARGO_PKG_AUTHORS"), about = "A Redis server")]
struct Cli {
#[clap(name = "port", long = "--port")]
port: Option<String>,
}