search: add --full flag to show node content in results
Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
63253f102a
commit
01dd8e5ef9
1 changed files with 15 additions and 3 deletions
|
|
@ -71,6 +71,9 @@ enum Command {
|
|||
/// Show more results
|
||||
#[arg(long)]
|
||||
expand: bool,
|
||||
/// Show node content, not just keys
|
||||
#[arg(long)]
|
||||
full: bool,
|
||||
/// Show debug output for each pipeline stage
|
||||
#[arg(long)]
|
||||
debug: bool,
|
||||
|
|
@ -478,8 +481,8 @@ fn main() {
|
|||
let cli = Cli::parse();
|
||||
|
||||
let result = match cli.command {
|
||||
Command::Search { query, pipeline, expand, debug }
|
||||
=> cmd_search(&query, &pipeline, expand, debug),
|
||||
Command::Search { query, pipeline, expand, full, debug }
|
||||
=> cmd_search(&query, &pipeline, expand, full, debug),
|
||||
Command::Init => cmd_init(),
|
||||
Command::Migrate => cmd_migrate(),
|
||||
Command::Health => cmd_health(),
|
||||
|
|
@ -584,7 +587,7 @@ fn main() {
|
|||
|
||||
// ── Command implementations ─────────────────────────────────────────
|
||||
|
||||
fn cmd_search(terms: &[String], pipeline_args: &[String], expand: bool, debug: bool) -> Result<(), String> {
|
||||
fn cmd_search(terms: &[String], pipeline_args: &[String], expand: bool, full: bool, debug: bool) -> Result<(), String> {
|
||||
use store::StoreView;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
|
@ -656,6 +659,15 @@ fn cmd_search(terms: &[String], pipeline_args: &[String], expand: bool, debug: b
|
|||
let marker = if r.is_direct { "→" } else { " " };
|
||||
let weight = view.node_weight(&r.key);
|
||||
println!("{}{:2}. [{:.2}/{:.2}] {}", marker, i + 1, r.activation, weight, r.key);
|
||||
if full {
|
||||
if let Some(content) = view.node_content(&r.key) {
|
||||
println!();
|
||||
for line in content.lines() {
|
||||
println!(" {}", line);
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue