support rebuilding the working set

This commit is contained in:
Dustin J. Mitchell
2020-01-19 15:55:15 -05:00
parent 12980da5fd
commit 61b2de132b
4 changed files with 157 additions and 5 deletions

View File

@@ -17,6 +17,8 @@ fn main() {
),
)
.subcommand(SubCommand::with_name("list").about("lists tasks"))
.subcommand(SubCommand::with_name("pending").about("lists pending tasks"))
.subcommand(SubCommand::with_name("gc").about("run garbage collection"))
.get_matches();
let mut replica = Replica::new(
@@ -38,10 +40,21 @@ fn main() {
.unwrap();
}
("list", _) => {
for task in replica.all_tasks().unwrap() {
println!("{:?}", task);
for (uuid, task) in replica.all_tasks().unwrap() {
println!("{} - {:?}", uuid, task);
}
}
("pending", _) => {
let working_set = replica.working_set().unwrap();
for i in 1..working_set.len() {
if let Some((ref uuid, ref task)) = working_set[i] {
println!("{}: {} - {:?}", i, uuid, task);
}
}
}
("gc", _) => {
replica.gc().unwrap();
}
("", None) => {
unreachable!();
}