Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-fallback to list options if argument not provided #13

Open
DarthBenro008 opened this issue Aug 3, 2021 · 0 comments
Open

Auto-fallback to list options if argument not provided #13

DarthBenro008 opened this issue Aug 3, 2021 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects

Comments

@DarthBenro008
Copy link
Owner

Right now you need to provide an positional argument to rchore tasks done <pos> or rchore tasks delete <pos>. It would be really nice if you could fall back to a list option presented to the user when the position is not passed, something like what already rchore task-list update or rchore task-list delete does.

Sample:
image

Relevant Codebase:

pub fn delete_task(&self, pos: usize) -> anyhow::Result<()> {
let resp = &self.client.localdb.get_data()?;
let task = resp.get(pos - 1).unwrap();
let new_resp = &self
.client
.delete_task(task.id.as_ref().unwrap().to_string());
match new_resp {
Ok(_res) => {
let _ = self
.client
.localdb
.delete_task(task.id.as_ref().unwrap().to_string());
print_success(format!("Task {} has been deleted!", &task.title))
}
Err(err) => print_error("deleting the task", err),
}
Ok(())
}
}

pub fn complete_task(&self, pos: usize, is_completed: bool) -> anyhow::Result<()> {
let resp = &self.client.localdb.get_data()?;
let mut task = resp.get(pos - 1).unwrap().clone();
task.status = if is_completed {
String::from("completed")
} else {
String::from("needsAction")
};
let new_resp = &self.client.update_task(task);
match new_resp {
Ok(task) => {
let _ = self.client.localdb.update_task(task.clone());
if is_completed {
print_success(format!("Task {} marked as completed!", task.title))
} else {
print_warning(format!("Task {} marked as incomplete!", task.title))
}
}
Err(err) => print_error("marking task complete", err),
}
Ok(())
}

@DarthBenro008 DarthBenro008 added help wanted Extra attention is needed good first issue Good for newcomers labels Aug 3, 2021
@DarthBenro008 DarthBenro008 added this to To do in v1.0.0 via automation Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
v1.0.0
To do
Development

No branches or pull requests

1 participant