[pre-commit.ci] pre-commit autoupdate (#3942)
Some checks are pending
checks / Check & Clippy (push) Waiting to run
checks / Formatting (push) Waiting to run
checks / Cargo Metadata (push) Waiting to run
release-tests / check-tarball (push) Waiting to run
tests / coverage (push) Waiting to run
tests / tests (Mac OS 12.latest) (push) Blocked by required conditions
tests / tests (Mac OS 13.latest) (push) Blocked by required conditions
tests / Cargo Test (push) Waiting to run
tests / tests (arch, Archlinux Base (Rolling), ubuntu-latest) (push) Blocked by required conditions
tests / tests (debiantesting, Debian Testing, ubuntu-latest) (push) Blocked by required conditions
tests / tests (fedora40, Fedora 40, ubuntu-latest) (push) Blocked by required conditions
tests / tests (fedora41, Fedora 41, ubuntu-latest) (push) Blocked by required conditions
tests / tests (opensuse, OpenSUSE Tumbleweed (Rolling), ubuntu-latest) (push) Blocked by required conditions
tests / tests (ubuntu2004, Ubuntu 20.04, ubuntu-latest) (push) Blocked by required conditions
tests / tests (ubuntu2204, Ubuntu 22.04, ubuntu-latest) (push) Blocked by required conditions

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/mirrors-clang-format: v20.1.8 → v21.1.0](https://github.com/pre-commit/mirrors-clang-format/compare/v20.1.8...v21.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot] 2025-09-01 16:31:25 -04:00 committed by GitHub
parent f41a16a0a5
commit ed5e0a52a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 114 additions and 114 deletions

View file

@ -9,7 +9,7 @@ repos:
- id: check-yaml - id: check-yaml
- id: check-added-large-files - id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format - repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8 rev: v21.1.0
hooks: hooks:
- id: clang-format - id: clang-format
types_or: [c++, c] types_or: [c++, c]

View file

@ -46,36 +46,36 @@ class Context {
Context() = default; // Default constructor Context() = default; // Default constructor
~Context(); // Destructor ~Context(); // Destructor
Context(const Context &); Context(const Context&);
Context &operator=(const Context &); Context& operator=(const Context&);
static Context &getContext(); static Context& getContext();
static void setContext(Context *); static void setContext(Context*);
int initialize(int, const char **); // all startup int initialize(int, const char**); // all startup
int run(); int run();
int dispatch(std::string &); // command handler dispatch int dispatch(std::string&); // command handler dispatch
int getWidth(); // determine terminal width int getWidth(); // determine terminal width
int getHeight(); // determine terminal height int getHeight(); // determine terminal height
std::string getTaskContext(const std::string &, std::string, bool fallback = true); std::string getTaskContext(const std::string&, std::string, bool fallback = true);
const std::vector<std::string> getColumns() const; const std::vector<std::string> getColumns() const;
void getLimits(int &, int &); void getLimits(int&, int&);
bool color(); // TTY or <other>? bool color(); // TTY or <other>?
bool verbose(const std::string &); // Verbosity control bool verbose(const std::string&); // Verbosity control
void header(const std::string &); // Header message sink void header(const std::string&); // Header message sink
void footnote(const std::string &); // Footnote message sink void footnote(const std::string&); // Footnote message sink
void debug(const std::string &); // Debug message sink void debug(const std::string&); // Debug message sink
void error(const std::string &); // Error message sink - non-maskable void error(const std::string&); // Error message sink - non-maskable
void decomposeSortField(const std::string &, std::string &, bool &, bool &); void decomposeSortField(const std::string&, std::string&, bool&, bool&);
void debugTiming(const std::string &, const Timer &); void debugTiming(const std::string&, const Timer&);
CurrentTask withCurrentTask(const Task *); CurrentTask withCurrentTask(const Task*);
friend class CurrentTask; friend class CurrentTask;
private: private:
@ -86,7 +86,7 @@ class Context {
void loadAliases(); void loadAliases();
void propagateDebug(); void propagateDebug();
static Context *context; static Context* context;
public: public:
CLI2 cli2{}; CLI2 cli2{};
@ -104,8 +104,8 @@ class Context {
std::vector<std::string> footnotes{}; std::vector<std::string> footnotes{};
std::vector<std::string> errors{}; std::vector<std::string> errors{};
std::vector<std::string> debugMessages{}; std::vector<std::string> debugMessages{};
std::map<std::string, Command *> commands{}; std::map<std::string, Command*> commands{};
std::map<std::string, Column *> columns{}; std::map<std::string, Column*> columns{};
int terminal_width{0}; int terminal_width{0};
int terminal_height{0}; int terminal_height{0};
@ -121,7 +121,7 @@ class Context {
long time_hooks_us{0}; long time_hooks_us{0};
// the current task for DOM references, or NULL if there is no task // the current task for DOM references, or NULL if there is no task
const Task *currentTask{NULL}; const Task* currentTask{NULL};
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -132,10 +132,10 @@ class CurrentTask {
~CurrentTask(); ~CurrentTask();
private: private:
CurrentTask(Context &context, const Task *previous); CurrentTask(Context& context, const Task* previous);
Context &context; Context& context;
const Task *previous; const Task* previous;
friend class Context; friend class Context;
}; };

View file

@ -33,43 +33,43 @@
#include <string> #include <string>
#include <vector> #include <vector>
bool domSource(const std::string &, Variant &); bool domSource(const std::string&, Variant&);
class Eval { class Eval {
public: public:
Eval(); Eval();
void addSource(bool (*fn)(const std::string &, Variant &)); void addSource(bool (*fn)(const std::string&, Variant&));
void evaluateInfixExpression(const std::string &, Variant &) const; void evaluateInfixExpression(const std::string&, Variant&) const;
void evaluatePostfixExpression(const std::string &, Variant &) const; void evaluatePostfixExpression(const std::string&, Variant&) const;
void compileExpression(const std::vector<std::pair<std::string, Lexer::Type>> &); void compileExpression(const std::vector<std::pair<std::string, Lexer::Type>>&);
void evaluateCompiledExpression(Variant &); void evaluateCompiledExpression(Variant&);
void debug(bool); void debug(bool);
static std::vector<std::string> getOperators(); static std::vector<std::string> getOperators();
static std::vector<std::string> getBinaryOperators(); static std::vector<std::string> getBinaryOperators();
private: private:
void evaluatePostfixStack(const std::vector<std::pair<std::string, Lexer::Type>> &, void evaluatePostfixStack(const std::vector<std::pair<std::string, Lexer::Type>>&,
Variant &) const; Variant&) const;
void infixToPostfix(std::vector<std::pair<std::string, Lexer::Type>> &) const; void infixToPostfix(std::vector<std::pair<std::string, Lexer::Type>>&) const;
void infixParse(std::vector<std::pair<std::string, Lexer::Type>> &) const; void infixParse(std::vector<std::pair<std::string, Lexer::Type>>&) const;
bool parseLogical(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseLogical(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseRegex(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseRegex(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseEquality(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseEquality(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseComparative(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseComparative(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseArithmetic(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseArithmetic(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseGeometric(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseGeometric(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseTag(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseTag(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseUnary(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseUnary(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseExponent(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parseExponent(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parsePrimitive(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const; bool parsePrimitive(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool identifyOperator(const std::string &, char &, unsigned int &, char &) const; bool identifyOperator(const std::string&, char&, unsigned int&, char&) const;
std::string dump(std::vector<std::pair<std::string, Lexer::Type>> &) const; std::string dump(std::vector<std::pair<std::string, Lexer::Type>>&) const;
private: private:
std::vector<bool (*)(const std::string &, Variant &)> _sources{}; std::vector<bool (*)(const std::string&, Variant&)> _sources{};
bool _debug{false}; bool _debug{false};
std::vector<std::pair<std::string, Lexer::Type>> _compiled{}; std::vector<std::pair<std::string, Lexer::Type>> _compiled{};
}; };

View file

@ -39,14 +39,14 @@
// type. // type.
class Operation { class Operation {
public: public:
explicit Operation(const tc::Operation &); explicit Operation(const tc::Operation&);
Operation(const Operation &other) = default; Operation(const Operation& other) = default;
Operation &operator=(const Operation &other); Operation& operator=(const Operation& other);
// Create a vector of Operations given the result of `Replica::get_undo_operations` or // Create a vector of Operations given the result of `Replica::get_undo_operations` or
// `Replica::get_task_operations`. The resulting vector must not outlive the input `rust::Vec`. // `Replica::get_task_operations`. The resulting vector must not outlive the input `rust::Vec`.
static std::vector<Operation> operations(const rust::Vec<tc::Operation> &); static std::vector<Operation> operations(const rust::Vec<tc::Operation>&);
// Methods from the underlying `tc::Operation`. // Methods from the underlying `tc::Operation`.
bool is_create() const { return op->is_create(); } bool is_create() const { return op->is_create(); }
@ -79,10 +79,10 @@ class Operation {
// Define a partial order on Operations: // Define a partial order on Operations:
// - Create < Update < Delete < UndoPoint // - Create < Update < Delete < UndoPoint
// - Given two updates, sort by timestamp // - Given two updates, sort by timestamp
bool operator<(const Operation &other) const; bool operator<(const Operation& other) const;
private: private:
const tc::Operation *op; const tc::Operation* op;
}; };
#endif #endif

View file

@ -44,12 +44,12 @@ class TDB2 {
TDB2() = default; TDB2() = default;
void open_replica(const std::string &, bool create_if_missing, bool read_write); void open_replica(const std::string&, bool create_if_missing, bool read_write);
void open_replica_in_memory(); void open_replica_in_memory();
void add(Task &); void add(Task&);
void modify(Task &); void modify(Task&);
void purge(Task &); void purge(Task&);
void get_changes(std::vector<Task> &); void get_changes(std::vector<Task>&);
void gc(); void gc();
void expire_tasks(); void expire_tasks();
int latest_id(); int latest_id();
@ -58,20 +58,20 @@ class TDB2 {
const std::vector<Task> all_tasks(); const std::vector<Task> all_tasks();
const std::vector<Task> pending_tasks(); const std::vector<Task> pending_tasks();
const std::vector<Task> completed_tasks(); const std::vector<Task> completed_tasks();
bool get(int, Task &); bool get(int, Task&);
bool get(const std::string &, Task &); bool get(const std::string&, Task&);
bool has(const std::string &); bool has(const std::string&);
const std::vector<Task> siblings(Task &); const std::vector<Task> siblings(Task&);
const std::vector<Task> children(Task &); const std::vector<Task> children(Task&);
// ID <--> UUID mapping. // ID <--> UUID mapping.
std::string uuid(int); std::string uuid(int);
int id(const std::string &); int id(const std::string&);
int num_local_changes(); int num_local_changes();
int num_reverts_possible(); int num_reverts_possible();
rust::Box<tc::Replica> &replica(); rust::Box<tc::Replica>& replica();
private: private:
std::optional<rust::Box<tc::Replica>> _replica; std::optional<rust::Box<tc::Replica>> _replica;
@ -85,8 +85,8 @@ class TDB2 {
// UUID -> Task containing all tasks modified in this invocation. // UUID -> Task containing all tasks modified in this invocation.
std::map<std::string, Task> changes; std::map<std::string, Task> changes;
const rust::Box<tc::WorkingSet> &working_set(); const rust::Box<tc::WorkingSet>& working_set();
void maybe_add_undo_point(rust::Vec<tc::Operation> &); void maybe_add_undo_point(rust::Vec<tc::Operation>&);
}; };
#endif #endif

View file

@ -66,32 +66,32 @@ Version Version::Current() { return Version(PACKAGE_VERSION); }
bool Version::is_valid() const { return major >= 0; } bool Version::is_valid() const { return major >= 0; }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Version::operator<(const Version &other) const { bool Version::operator<(const Version& other) const {
return std::tie(major, minor, patch) < std::tie(other.major, other.minor, other.patch); return std::tie(major, minor, patch) < std::tie(other.major, other.minor, other.patch);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Version::operator<=(const Version &other) const { bool Version::operator<=(const Version& other) const {
return std::tie(major, minor, patch) <= std::tie(other.major, other.minor, other.patch); return std::tie(major, minor, patch) <= std::tie(other.major, other.minor, other.patch);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Version::operator>(const Version &other) const { bool Version::operator>(const Version& other) const {
return std::tie(major, minor, patch) > std::tie(other.major, other.minor, other.patch); return std::tie(major, minor, patch) > std::tie(other.major, other.minor, other.patch);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Version::operator>=(const Version &other) const { bool Version::operator>=(const Version& other) const {
return std::tie(major, minor, patch) >= std::tie(other.major, other.minor, other.patch); return std::tie(major, minor, patch) >= std::tie(other.major, other.minor, other.patch);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Version::operator==(const Version &other) const { bool Version::operator==(const Version& other) const {
return std::tie(major, minor, patch) == std::tie(other.major, other.minor, other.patch); return std::tie(major, minor, patch) == std::tie(other.major, other.minor, other.patch);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Version::operator!=(const Version &other) const { bool Version::operator!=(const Version& other) const {
return std::tie(major, minor, patch) != std::tie(other.major, other.minor, other.patch); return std::tie(major, minor, patch) != std::tie(other.major, other.minor, other.patch);
} }
@ -107,7 +107,7 @@ Version::operator std::string() const {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::ostream &operator<<(std::ostream &os, const Version &version) { std::ostream& operator<<(std::ostream& os, const Version& version) {
os << std::string(version); os << std::string(version);
return os; return os;
} }

View file

@ -39,10 +39,10 @@ class Version {
// Create an invalid version. // Create an invalid version.
Version() = default; Version() = default;
Version(const Version &other) = default; Version(const Version& other) = default;
Version(Version &&other) = default; Version(Version&& other) = default;
Version &operator=(const Version &) = default; Version& operator=(const Version&) = default;
Version &operator=(Version &&) = default; Version& operator=(Version&&) = default;
// Return a version representing the release being built. // Return a version representing the release being built.
static Version Current(); static Version Current();
@ -50,17 +50,17 @@ class Version {
bool is_valid() const; bool is_valid() const;
// Compare versions. // Compare versions.
bool operator<(const Version &) const; bool operator<(const Version&) const;
bool operator<=(const Version &) const; bool operator<=(const Version&) const;
bool operator>(const Version &) const; bool operator>(const Version&) const;
bool operator>=(const Version &) const; bool operator>=(const Version&) const;
bool operator==(const Version &) const; bool operator==(const Version&) const;
bool operator!=(const Version &) const; bool operator!=(const Version&) const;
// Convert back to a string. // Convert back to a string.
operator std::string() const; operator std::string() const;
friend std::ostream &operator<<(std::ostream &os, const Version &version); friend std::ostream& operator<<(std::ostream& os, const Version& version);
private: private:
int major = -1; int major = -1;

View file

@ -35,10 +35,10 @@
class CmdImportV2 : public Command { class CmdImportV2 : public Command {
public: public:
CmdImportV2(); CmdImportV2();
int execute(std::string &); int execute(std::string&);
private: private:
int import(const std::vector<std::map<std::string, std::string>> &task_data); int import(const std::vector<std::map<std::string, std::string>>& task_data);
}; };
#endif #endif

View file

@ -58,7 +58,7 @@ CmdModify::CmdModify() {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdModify::execute(std::string &) { int CmdModify::execute(std::string&) {
auto rc = 0; auto rc = 0;
// Apply filter. // Apply filter.
@ -77,7 +77,7 @@ int CmdModify::execute(std::string &) {
if (filtered.size() > 1) { if (filtered.size() > 1) {
feedback_affected("This command will alter {1} tasks.", filtered.size()); feedback_affected("This command will alter {1} tasks.", filtered.size());
} }
for (auto &task : filtered) { for (auto& task : filtered) {
Task before(task); Task before(task);
task.modify(Task::modReplace); task.modify(Task::modReplace);
@ -99,7 +99,7 @@ int CmdModify::execute(std::string &) {
} }
// Now list the project changes. // Now list the project changes.
for (const auto &change : projectChanges) for (const auto& change : projectChanges)
if (change.first != "") Context::getContext().footnote(change.second); if (change.first != "") Context::getContext().footnote(change.second);
feedback_affected(count == 1 ? "Modified {1} task." : "Modified {1} tasks.", count); feedback_affected(count == 1 ? "Modified {1} task." : "Modified {1} tasks.", count);
@ -108,7 +108,7 @@ int CmdModify::execute(std::string &) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TODO Why is this not in Task::validate? // TODO Why is this not in Task::validate?
void CmdModify::checkConsistency(Task &before, Task &after) { void CmdModify::checkConsistency(Task& before, Task& after) {
// Perform some logical consistency checks. // Perform some logical consistency checks.
if (after.has("recur") && !after.has("due") && !before.has("due")) if (after.has("recur") && !after.has("due") && !before.has("due"))
throw std::string("You cannot specify a recurring task without a due date."); throw std::string("You cannot specify a recurring task without a due date.");
@ -126,8 +126,8 @@ void CmdModify::checkConsistency(Task &before, Task &after) {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdModify::modifyAndUpdate(Task &before, Task &after, int CmdModify::modifyAndUpdate(Task& before, Task& after,
std::map<std::string, std::string> *projectChanges /* = NULL */) { std::map<std::string, std::string>* projectChanges /* = NULL */) {
// This task. // This task.
auto count = 1; auto count = 1;
@ -150,14 +150,14 @@ int CmdModify::modifyAndUpdate(Task &before, Task &after,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdModify::modifyRecurrenceSiblings( int CmdModify::modifyRecurrenceSiblings(
Task &task, std::map<std::string, std::string> *projectChanges /* = NULL */) { Task& task, std::map<std::string, std::string>* projectChanges /* = NULL */) {
auto count = 0; auto count = 0;
if ((Context::getContext().config.get("recurrence.confirmation") == "prompt" && if ((Context::getContext().config.get("recurrence.confirmation") == "prompt" &&
confirm(STRING_CMD_MODIFY_RECUR)) || confirm(STRING_CMD_MODIFY_RECUR)) ||
Context::getContext().config.getBoolean("recurrence.confirmation")) { Context::getContext().config.getBoolean("recurrence.confirmation")) {
std::vector<Task> siblings = Context::getContext().tdb2.siblings(task); std::vector<Task> siblings = Context::getContext().tdb2.siblings(task);
for (auto &sibling : siblings) { for (auto& sibling : siblings) {
Task alternate(sibling); Task alternate(sibling);
sibling.modify(Task::modReplace); sibling.modify(Task::modReplace);
updateRecurrenceMask(sibling); updateRecurrenceMask(sibling);
@ -181,7 +181,7 @@ int CmdModify::modifyRecurrenceSiblings(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdModify::modifyRecurrenceParent( int CmdModify::modifyRecurrenceParent(
Task &task, std::map<std::string, std::string> *projectChanges /* = NULL */) { Task& task, std::map<std::string, std::string>* projectChanges /* = NULL */) {
auto count = 0; auto count = 0;
auto children = Context::getContext().tdb2.children(task); auto children = Context::getContext().tdb2.children(task);
@ -189,7 +189,7 @@ int CmdModify::modifyRecurrenceParent(
((Context::getContext().config.get("recurrence.confirmation") == "prompt" && ((Context::getContext().config.get("recurrence.confirmation") == "prompt" &&
confirm(STRING_CMD_MODIFY_RECUR)) || confirm(STRING_CMD_MODIFY_RECUR)) ||
Context::getContext().config.getBoolean("recurrence.confirmation"))) { Context::getContext().config.getBoolean("recurrence.confirmation"))) {
for (auto &child : children) { for (auto& child : children) {
Task alternate(child); Task alternate(child);
child.modify(Task::modReplace); child.modify(Task::modReplace);
updateRecurrenceMask(child); updateRecurrenceMask(child);

View file

@ -34,14 +34,14 @@
class CmdModify : public Command { class CmdModify : public Command {
public: public:
CmdModify(); CmdModify();
int execute(std::string &); int execute(std::string&);
void checkConsistency(Task &before, Task &after); void checkConsistency(Task& before, Task& after);
int modifyAndUpdate(Task &before, Task &after, int modifyAndUpdate(Task& before, Task& after,
std::map<std::string, std::string> *projectChanges = nullptr); std::map<std::string, std::string>* projectChanges = nullptr);
int modifyRecurrenceSiblings(Task &task, int modifyRecurrenceSiblings(Task& task,
std::map<std::string, std::string> *projectChanges = nullptr); std::map<std::string, std::string>* projectChanges = nullptr);
int modifyRecurrenceParent(Task &task, int modifyRecurrenceParent(Task& task,
std::map<std::string, std::string> *projectChanges = nullptr); std::map<std::string, std::string>* projectChanges = nullptr);
}; };
#endif #endif

View file

@ -36,10 +36,10 @@
class CmdUndo : public Command { class CmdUndo : public Command {
public: public:
CmdUndo(); CmdUndo();
int execute(std::string &); int execute(std::string&);
private: private:
bool confirm_revert(const std::vector<Operation> &); bool confirm_revert(const std::vector<Operation>&);
}; };
#endif #endif

View file

@ -46,11 +46,11 @@ int usage() {
} // namespace } // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv) { int main(int argc, char** argv) {
if (!--argc) { if (!--argc) {
return usage(); return usage();
} }
char *datadir = *++argv; char* datadir = *++argv;
auto replica = tc::new_replica_on_disk(datadir, /*create_if_missing=*/true, /*read_write=*/true); auto replica = tc::new_replica_on_disk(datadir, /*create_if_missing=*/true, /*read_write=*/true);
auto uuid = tc::uuid_v4(); auto uuid = tc::uuid_v4();

View file

@ -41,7 +41,7 @@ std::string uuid2str(tc::Uuid uuid) { return static_cast<std::string>(uuid.to_st
// Tests for the basic cxxbridge functionality. This focuses on the methods with // Tests for the basic cxxbridge functionality. This focuses on the methods with
// complex cxxbridge implementations, rather than those with complex Rust // complex cxxbridge implementations, rather than those with complex Rust
// implementations but simple APIs, like sync. // implementations but simple APIs, like sync.
int TEST_NAME(int, char **) { int TEST_NAME(int, char**) {
UnitTest t; UnitTest t;
std::string str; std::string str;
@ -94,7 +94,7 @@ int TEST_NAME(int, char **) {
auto old_task = ops[5].get_old_task(); auto old_task = ops[5].get_old_task();
// old_task is in arbitrary order, so just check that status is in there. // old_task is in arbitrary order, so just check that status is in there.
bool found = false; bool found = false;
for (auto &pv : old_task) { for (auto& pv : old_task) {
std::string p = static_cast<std::string>(pv.prop); std::string p = static_cast<std::string>(pv.prop);
if (p == "status") { if (p == "status") {
std::string v = static_cast<std::string>(pv.value); std::string v = static_cast<std::string>(pv.value);
@ -131,7 +131,7 @@ int TEST_NAME(int, char **) {
auto all_tasks = replica->all_task_data(); auto all_tasks = replica->all_task_data();
t.is(all_tasks.size(), (size_t)2, "now there are 2 tasks"); t.is(all_tasks.size(), (size_t)2, "now there are 2 tasks");
for (auto &maybe_task : all_tasks) { for (auto& maybe_task : all_tasks) {
t.ok(maybe_task.is_some(), "all_tasks is fully populated"); t.ok(maybe_task.is_some(), "all_tasks is fully populated");
auto task = maybe_task.take(); auto task = maybe_task.take();
if (task->get_uuid() == uuid) { if (task->get_uuid() == uuid) {
@ -144,7 +144,7 @@ int TEST_NAME(int, char **) {
try { try {
replica->sync_to_local("/does/not/exist", false); replica->sync_to_local("/does/not/exist", false);
// tc::new_replica_on_disk("/does/not/exist", false); // tc::new_replica_on_disk("/does/not/exist", false);
} catch (rust::Error &err) { } catch (rust::Error& err) {
t.is(err.what(), t.is(err.what(),
"unable to open database file: /does/not/exist/taskchampion-local-sync-server.sqlite3: " "unable to open database file: /does/not/exist/taskchampion-local-sync-server.sqlite3: "
"Error code 14: Unable to open the database file", "Error code 14: Unable to open the database file",