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

@@ -33,6 +33,25 @@
using namespace tc::ffi;
////////////////////////////////////////////////////////////////////////////////
tc::ReplicaGuard::ReplicaGuard (Replica &replica, Task &task) :
replica(replica),
task(task)
{
// "steal" the reference from the Replica and store it locally, so that any
// attempt to use the Replica will fail
tcreplica = replica.inner.release();
task.to_mut(tcreplica);
}
////////////////////////////////////////////////////////////////////////////////
tc::ReplicaGuard::~ReplicaGuard ()
{
task.to_immut();
// return the reference to the Replica.
replica.inner.reset(tcreplica);
}
////////////////////////////////////////////////////////////////////////////////
tc::Replica::Replica ()
{
@@ -113,6 +132,45 @@ tc::Task tc::Replica::new_task (tc::Status status, const std::string &descriptio
return Task (tctask);
}
////////////////////////////////////////////////////////////////////////////////
tc::Task tc::Replica::import_task_with_uuid (const std::string &uuid)
{
TCTask *tctask = tc_replica_import_task_with_uuid (&*inner, uuid2tc (uuid));
if (!tctask) {
throw replica_error ();
}
return Task (tctask);
}
////////////////////////////////////////////////////////////////////////////////
void tc::Replica::undo (int32_t *undone_out)
{
auto res = tc_replica_undo (&*inner, undone_out);
if (res != TC_RESULT_OK) {
throw replica_error ();
}
}
////////////////////////////////////////////////////////////////////////////////
int64_t tc::Replica::num_local_operations ()
{
auto num = tc_replica_num_local_operations (&*inner);
if (num < 0) {
throw replica_error ();
}
return num;
}
////////////////////////////////////////////////////////////////////////////////
int64_t tc::Replica::num_undo_points ()
{
auto num = tc_replica_num_undo_points (&*inner);
if (num < 0) {
throw replica_error ();
}
return num;
}
////////////////////////////////////////////////////////////////////////////////
std::vector<tc::Task> tc::Replica::all_tasks ()
{
@@ -134,14 +192,19 @@ std::vector<tc::Task> tc::Replica::all_tasks ()
}
////////////////////////////////////////////////////////////////////////////////
void tc::Replica::rebuild_working_set ()
void tc::Replica::rebuild_working_set (bool force)
{
auto res = tc_replica_rebuild_working_set (&*inner, true);
auto res = tc_replica_rebuild_working_set (&*inner, force);
if (res != TC_RESULT_OK) {
throw replica_error ();
}
}
////////////////////////////////////////////////////////////////////////////////
tc::ReplicaGuard tc::Replica::mutate_task (tc::Task &task) {
return ReplicaGuard(*this, task);
}
////////////////////////////////////////////////////////////////////////////////
std::string tc::Replica::replica_error () {
return replica_error (tc_replica_error (&*inner));