Skip to content

Commit 6a3881d

Browse files
authored
Merge pull request #747 from Migorithm/chore/lrpush-hint
chore: cli hint for lpush rpush
2 parents 9dfd345 + 0328166 commit 6a3881d

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

duva-client/src/cli/editor/completion.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub(crate) static COMMANDS: &[&str] = &[
3232
"cluster reshard",
3333
"info replication",
3434
"replicaof",
35+
"lpush",
36+
"rpush",
3537
];
3638

3739
macro_rules! new_pair {
@@ -143,6 +145,15 @@ impl Completer for DuvaHinter {
143145
candidates.push(new_pair!("key"));
144146
}
145147
},
148+
| "lpush" | "rpush" => {
149+
if previous_words.len() == 1 {
150+
// Suggest "key" after set
151+
candidates.push(new_pair!("key"));
152+
} else if previous_words.len() > 1 {
153+
// Suggest "value" after set key
154+
candidates.push(new_pair!("value"));
155+
}
156+
},
146157
| "get" | "incr" | "decr" | "ttl" => {
147158
if previous_words.len() == 1 {
148159
// Suggest "index" after get key

duva-client/src/cli/editor/hints.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ pub(crate) fn default_hints() -> HashSet<CommandHint> {
140140
set.insert(CommandHint::new("del key [key ...]", "del "));
141141
set.insert(CommandHint::new("ttl key", "ttl "));
142142
set.insert(CommandHint::new("replicaof host port", "replicaof "));
143+
set.insert(CommandHint::new("lpush key value [value ...]", "lpush "));
144+
set.insert(CommandHint::new("rpush key value [value ...]", "rpush "));
143145

144146
set
145147
}
@@ -168,6 +170,7 @@ pub(crate) fn dynamic_hints() -> HashMap<&'static str, Vec<DynamicHint>> {
168170
vec![hint!("key value", 0), hint!("value", 1), hint!("[px expr]", 2), hint!("expr", 3)],
169171
);
170172
map.insert("append", vec![hint!("key value", 0), hint!("value", 1)]);
173+
171174
map.insert("incrby", vec![hint!("key increment", 0), hint!("increment", 1)]);
172175
map.insert("decrby", vec![hint!("key decrement", 0), hint!("decrement", 1)]);
173176

@@ -178,6 +181,14 @@ pub(crate) fn dynamic_hints() -> HashMap<&'static str, Vec<DynamicHint>> {
178181
map.insert("exists", vec![hint!("key [key ...]", 0, repeat), hint!("[key ...]", 1, repeat)]);
179182
map.insert("del", vec![hint!("key [key ...]", 0, repeat), hint!("[key ...]", 1, repeat)]);
180183
map.insert("mget", vec![hint!("key [key ...]", 0, repeat), hint!("[key ...]", 1, repeat)]);
184+
map.insert(
185+
"lpush",
186+
vec![hint!("key value [value ...]", 0, repeat), hint!("[value ...]", 1, repeat)],
187+
);
188+
map.insert(
189+
"rpush",
190+
vec![hint!("key value [value ...]", 0, repeat), hint!("[value ...]", 1, repeat)],
191+
);
181192
map.insert("replicaof", vec![hint!("host port", 0), hint!("port", 1)]);
182193

183194
map

0 commit comments

Comments
 (0)