Added branch for searching files with tag
parent
fcd6292598
commit
93b0e0c373
13
src/tags.rs
13
src/tags.rs
|
@ -21,13 +21,18 @@ pub fn handle_files(args: FilesArgs) {
|
|||
JOIN tag ON tag.id = file_tag.tag_id"#
|
||||
.to_string();
|
||||
|
||||
let mut show_tags = true;
|
||||
|
||||
if let Some(query) = args.query {
|
||||
let path = PathBuf::from_str(&query).unwrap_or_default();
|
||||
match path.exists() {
|
||||
true => {
|
||||
sql.push_str(&format!(" WHERE path IN ('{}')", query));
|
||||
}
|
||||
false => todo!(),
|
||||
false => {
|
||||
sql.push_str(&format!(" WHERE tag.name LIKE '%{}%'", query));
|
||||
show_tags = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,7 +48,11 @@ pub fn handle_files(args: FilesArgs) {
|
|||
|
||||
let mut w = io::stdout();
|
||||
for (file, tags) in result {
|
||||
writeln!(&mut w, "{}: {}", file, tags).unwrap();
|
||||
if show_tags {
|
||||
writeln!(&mut w, "{}: {}", file, tags).unwrap();
|
||||
} else {
|
||||
writeln!(&mut w, "{}", file).unwrap();
|
||||
}
|
||||
}
|
||||
w.flush().unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue