forked from kent/consciousness
cli: kill cmd_list_keys
Redundant with query Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
ad59596335
commit
a6b93c2255
2 changed files with 0 additions and 41 deletions
|
|
@ -15,39 +15,6 @@ pub fn cmd_weight_set(key: &str, weight: f32) -> Result<(), String> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_list_keys(pattern: Option<&str>) -> Result<(), String> {
|
||||
let store = store::Store::load()?;
|
||||
let g = store.build_graph();
|
||||
|
||||
if let Some(pat) = pattern {
|
||||
let pat_lower = pat.to_lowercase();
|
||||
let (prefix, suffix, middle) = if pat_lower.starts_with('*') && pat_lower.ends_with('*') {
|
||||
(None, None, Some(pat_lower.trim_matches('*').to_string()))
|
||||
} else if pat_lower.starts_with('*') {
|
||||
(None, Some(pat_lower.trim_start_matches('*').to_string()), None)
|
||||
} else if pat_lower.ends_with('*') {
|
||||
(Some(pat_lower.trim_end_matches('*').to_string()), None, None)
|
||||
} else {
|
||||
(None, None, Some(pat_lower.clone()))
|
||||
};
|
||||
let mut keys: Vec<_> = store.nodes.keys()
|
||||
.filter(|k| {
|
||||
let kl = k.to_lowercase();
|
||||
if let Some(ref m) = middle { kl.contains(m.as_str()) }
|
||||
else if let Some(ref p) = prefix { kl.starts_with(p.as_str()) }
|
||||
else if let Some(ref s) = suffix { kl.ends_with(s.as_str()) }
|
||||
else { true }
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
keys.sort();
|
||||
for k in keys { println!("{}", k); }
|
||||
Ok(())
|
||||
} else {
|
||||
crate::query_parser::run_query(&store, &g, "* | sort key asc")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cmd_node_delete(key: &[String]) -> Result<(), String> {
|
||||
if key.is_empty() {
|
||||
return Err("node-delete requires a key".into());
|
||||
|
|
@ -189,4 +156,3 @@ pub fn cmd_edit(key: &[String]) -> Result<(), String> {
|
|||
println!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue