Skip to content

Commit 6d8a45e

Browse files
authored
Merge pull request #4 from zebp/zeb/find-all-tags
feet: list all tags
2 parents bddd9dc + 5510ad3 commit 6d8a45e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fn main() -> Result<(), GeneralError> {
108108
clap::arg!(-c --"in-cwd" [IN_CWD] "filters by paths in the current working directory"),
109109
clap::arg!([TAGS]),
110110
]))
111+
.subcommand(Command::new("tags").about("Get a list of all tags"))
111112
.get_matches();
112113

113114
match matches.subcommand() {
@@ -123,6 +124,14 @@ fn main() -> Result<(), GeneralError> {
123124
.unwrap_or_else(|_| sub_matches.is_present("in-cwd"));
124125
find_path(connection, &tags, in_cwd)?;
125126
}
127+
Some(("tags", _)) => {
128+
let mut statement = connection.prepare("SELECT DISTINCT tag FROM tagged;")?;
129+
let rows = statement.query_map([], |row| row.get::<usize, String>(0))?;
130+
131+
for row in rows {
132+
println!("{}", row?);
133+
}
134+
}
126135
_ => unreachable!("Exhausted list of subcommands and subcommand_required prevents `None`"),
127136
};
128137

0 commit comments

Comments
 (0)