Use Taskchampion to store Taskwarrior data

This replaces the TF2 task files with a TaskChampion replica.
This commit is contained in:
Dustin J. Mitchell
2022-12-15 02:52:47 +00:00
committed by Dustin J. Mitchell
parent 4b814bc602
commit 5bb9857984
24 changed files with 537 additions and 1362 deletions

View File

@@ -60,6 +60,18 @@ tc::Task& tc::Task::operator= (Task &&other) noexcept
return *this;
}
////////////////////////////////////////////////////////////////////////////////
void tc::Task::to_mut (TCReplica *replica)
{
tc_task_to_mut(&*inner, replica);
}
////////////////////////////////////////////////////////////////////////////////
void tc::Task::to_immut ()
{
tc_task_to_immut(&*inner);
}
////////////////////////////////////////////////////////////////////////////////
std::string tc::Task::get_uuid () const
{
@@ -100,6 +112,15 @@ std::string tc::Task::get_description () const
}
////////////////////////////////////////////////////////////////////////////////
std::optional<std::string> tc::Task::get_value (std::string property) const
{
auto maybe_desc = tc_task_get_value (&*inner, string2tc(property));
if (maybe_desc.ptr == NULL) {
return std::nullopt;
}
return std::make_optional(tc2string(maybe_desc));
}
bool tc::Task::is_waiting () const
{
return tc_task_is_waiting (&*inner);
@@ -123,6 +144,40 @@ bool tc::Task::is_blocking () const
return tc_task_is_blocking (&*inner);
}
////////////////////////////////////////////////////////////////////////////////
void tc::Task::set_status (tc::Status status)
{
TCResult res = tc_task_set_status (&*inner, (TCStatus)status);
if (res != TC_RESULT_OK) {
throw task_error ();
}
}
////////////////////////////////////////////////////////////////////////////////
void tc::Task::set_value (std::string property, std::optional<std::string> value)
{
TCResult res;
if (value.has_value()) {
res = tc_task_set_value (&*inner, string2tc(property), string2tc(value.value()));
} else {
TCString nullstr;
nullstr.ptr = NULL;
res = tc_task_set_value (&*inner, string2tc(property), nullstr);
}
if (res != TC_RESULT_OK) {
throw task_error ();
}
}
////////////////////////////////////////////////////////////////////////////////
void tc::Task::set_modified (time_t modified)
{
TCResult res = tc_task_set_modified (&*inner, modified);
if (res != TC_RESULT_OK) {
throw task_error ();
}
}
////////////////////////////////////////////////////////////////////////////////
std::string tc::Task::task_error () const {
TCString error = tc_task_error (&*inner);