Merge pull request #47 from djmitche/issue43
Update handling of working set and show id's more widely
This commit is contained in:
@@ -30,11 +30,16 @@ define_subcommand! {
|
||||
|
||||
subcommand_invocation! {
|
||||
fn run(&self, command: &CommandInvocation) -> Fallible<()> {
|
||||
let task = shared::get_task(&mut command.get_replica(), &self.task)?;
|
||||
let mut replica = command.get_replica();
|
||||
let task = shared::get_task(&mut replica, &self.task)?;
|
||||
let uuid = task.get_uuid();
|
||||
|
||||
let mut t = Table::new();
|
||||
t.set_format(table::format());
|
||||
t.add_row(row![b->"Uuid", task.get_uuid()]);
|
||||
t.add_row(row![b->"Uuid", uuid]);
|
||||
if let Some(i) = replica.get_working_set_index(uuid)? {
|
||||
t.add_row(row![b->"Id", i]);
|
||||
}
|
||||
t.add_row(row![b->"Description", task.get_description()]);
|
||||
t.add_row(row![b->"Status", task.get_status()]);
|
||||
t.printstd();
|
||||
|
||||
@@ -23,11 +23,16 @@ define_subcommand! {
|
||||
|
||||
subcommand_invocation! {
|
||||
fn run(&self, command: &CommandInvocation) -> Fallible<()> {
|
||||
let mut replica = command.get_replica();
|
||||
let mut t = Table::new();
|
||||
t.set_format(table::format());
|
||||
t.set_titles(row![b->"uuid", b->"description"]);
|
||||
for (uuid, task) in command.get_replica().all_tasks().unwrap() {
|
||||
t.add_row(row![uuid, task.get_description()]);
|
||||
t.set_titles(row![b->"id", b->"description"]);
|
||||
for (uuid, task) in replica.all_tasks().unwrap() {
|
||||
let mut id = uuid.to_string();
|
||||
if let Some(i) = replica.get_working_set_index(&uuid)? {
|
||||
id = i.to_string();
|
||||
}
|
||||
t.add_row(row![id, task.get_description()]);
|
||||
}
|
||||
t.printstd();
|
||||
Ok(())
|
||||
|
||||
@@ -12,13 +12,10 @@ pub(super) fn get_task<S: AsRef<str>>(replica: &mut Replica, task_arg: S) -> Fal
|
||||
let task_arg = task_arg.as_ref();
|
||||
|
||||
// first try treating task as a working-set reference
|
||||
match task_arg.parse::<u64>() {
|
||||
match task_arg.parse::<usize>() {
|
||||
Ok(i) => {
|
||||
let mut working_set = replica.working_set().unwrap();
|
||||
if i > 0 && i < working_set.len() as u64 {
|
||||
if let Some(task) = working_set[i as usize].take() {
|
||||
return Ok(task);
|
||||
}
|
||||
if let Some(task) = replica.get_working_set_task(i)? {
|
||||
return Ok(task);
|
||||
}
|
||||
}
|
||||
Err(_) => {}
|
||||
|
||||
Reference in New Issue
Block a user