Skip to content

Commit

Permalink
Fixed: build error due to redis-rs API changes
Browse files Browse the repository at this point in the history
    closes: #21
  • Loading branch information
sabledb-io committed Aug 1, 2024
1 parent b7d1b35 commit d793ad2
Showing 1 changed file with 57 additions and 6 deletions.
63 changes: 57 additions & 6 deletions sdb-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ fn interactive_loop(

rl.set_helper(Some(helper));
loop {
rl.helper_mut().expect("No helper").colored_prompt.clone_from(&colored_prompt);
rl.helper_mut()
.expect("No helper")
.colored_prompt
.clone_from(&colored_prompt);
let Ok(line) = rl.readline(&base_prompt) else {
break;
};
Expand Down Expand Up @@ -170,16 +173,23 @@ fn print_response_pretty(value: &Value, indent: usize, seq: Option<usize>) {
print_sequence(seq);
println_value("(nil)");
}
Value::Double(val) => {
print_sequence(seq);
println_value(format!("(double) {}", val));
}
Value::Int(val) => {
print_sequence(seq);
println_value(format!("(integer) {}", val));
}
Value::Data(ref val) => {
let s = String::from_utf8_lossy(val);
Value::Boolean(val) => {
print_sequence(seq);
println_value(format!(r#"{}"#, s));
println_value(format!("(boolean) {}", val));
}
Value::Bulk(ref values) => {
Value::BigNumber(val) => {
print_sequence(seq);
println_value(format!("(big number) {}", val));
}
Value::Array(ref values) | Value::Set(ref values) => {
if values.is_empty() {
print_indent(indent);
print_sequence(seq);
Expand All @@ -198,10 +208,51 @@ fn print_response_pretty(value: &Value, indent: usize, seq: Option<usize>) {
print_sequence(seq);
println_value("OK");
}
Value::Status(ref s) => {
Value::SimpleString(ref s) => {
print_sequence(seq);
println_value(format!(r#""{}""#, s));
}
Value::BulkString(ref s) => {
print_sequence(seq);
println_value(format!(r#""{}""#, String::from_utf8_lossy(s)));
}
Value::Map(ref m) => {
print_sequence(seq);
let mut new_seq = 1usize;
for (k, v) in m {
print_response_pretty(k, indent + 4, Some(new_seq));
new_seq += 1;
print_response_pretty(v, indent + 4, Some(new_seq));
new_seq += 1;
}
}
Value::Push { kind, data } => {
print_sequence(seq);
println_value(kind);
let mut new_seq = 1usize;
for v in data {
print_response_pretty(v, indent + 4, Some(new_seq));
new_seq += 1;
}
}
Value::Attribute { data, attributes } => {
print_sequence(seq);
print_response_pretty(&data, indent, None);
let mut new_seq = 1usize;
for (k, v) in attributes {
print_response_pretty(k, indent + 4, Some(new_seq));
new_seq += 1;
print_response_pretty(v, indent + 4, Some(new_seq));
new_seq += 1;
}
}
Value::VerbatimString { format: _, text } => {
print_sequence(seq);
println_value(format!(r#""{}""#, text));
}
Value::ServerError(e) => {
println_value(format!(r#""{:?}""#, e));
}
}
}

Expand Down

0 comments on commit d793ad2

Please sign in to comment.