diff --git a/herodb/src/cmd.rs b/herodb/src/cmd.rs index eef93c4..3403fc5 100644 --- a/herodb/src/cmd.rs +++ b/herodb/src/cmd.rs @@ -40,6 +40,7 @@ pub enum Cmd { Client(Vec), ClientSetName(String), ClientGetName, + Command(Vec), // List commands LPush(String, Vec), RPush(String, Vec), @@ -345,6 +346,10 @@ impl Cmd { Cmd::Client(vec![]) } } + "command" => { + let args = if cmd.len() > 1 { cmd[1..].to_vec() } else { vec![] }; + Cmd::Command(args) + } "lpush" => { if cmd.len() < 3 { return Err(DBError(format!("wrong number of arguments for LPUSH command"))); @@ -540,6 +545,7 @@ impl Cmd { Cmd::Client(_) => Ok(Protocol::SimpleString("OK".to_string())), Cmd::ClientSetName(name) => client_setname_cmd(server, &name).await, Cmd::ClientGetName => client_getname_cmd(server).await, + Cmd::Command(_) => Ok(Protocol::Array(vec![])), // List commands Cmd::LPush(key, elements) => lpush_cmd(server, &key, &elements).await, Cmd::RPush(key, elements) => rpush_cmd(server, &key, &elements).await, @@ -862,17 +868,19 @@ async fn info_cmd(server: &Server, section: &Option) -> Result match s.as_str() { - "replication" => Ok(Protocol::BulkString( - "role:master\nmaster_replid:8371b4fb1155b71f4a04d3e1bc3e18c4a990aeea\nmaster_repl_offset:0\n".to_string() - )), - _ => Err(DBError(format!("unsupported section {:?}", s))), - }, - None => { - Ok(Protocol::BulkString(info_string)) + Some(s) => { + let sl = s.to_lowercase(); + if sl == "replication" { + Ok(Protocol::BulkString( + "role:master\nmaster_replid:8371b4fb1155b71f4a04d3e1bc3e18c4a990aeea\nmaster_repl_offset:0\n".to_string() + )) + } else { + // Return general info for unknown sections (e.g., SERVER) + Ok(Protocol::BulkString(info_string)) + } } + None => Ok(Protocol::BulkString(info_string)), } }