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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,12 +203,6 @@ enum NodeCmd {
|
|||
/// New key
|
||||
new_key: String,
|
||||
},
|
||||
/// List all node keys (one per line, optional glob)
|
||||
#[command(name = "list")]
|
||||
List {
|
||||
/// Glob pattern to filter keys
|
||||
pattern: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
|
|
@ -494,7 +488,6 @@ impl Run for NodeCmd {
|
|||
match self {
|
||||
Self::Delete { key } => cli::node::cmd_node_delete(&key),
|
||||
Self::Rename { old_key, new_key } => cli::node::cmd_node_rename(&old_key, &new_key),
|
||||
Self::List { pattern } => cli::node::cmd_list_keys(pattern.as_deref()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue