Declare in corresponding header files and dissolve main.h (#3796)

* Declare in corresponding header files and dissolve main.h

Apply include-what-you-use

* Remove further unncessary includes

* Incorporate review comment

* Do not declare static functions and variables in header

* Adapt test

* [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:
Tobias Predel 2025-03-01 20:47:42 +01:00 committed by GitHub
parent 55c02f5420
commit 81ca04fc8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 402 additions and 176 deletions

View file

@ -36,7 +36,8 @@
#include <Version.h>
#include <assert.h>
#include <format.h>
#include <main.h>
#include <recur.h>
#include <rules.h>
#include <rust/cxx.h>
#include <shared.h>
#include <stdlib.h>

View file

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2024, Tomas Babej, Paul Beckingham, Federico Hernandez.
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -24,8 +25,8 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_OPERATIOn
#define INCLUDED_OPERATIOn
#ifndef INCLUDED_OPERATION
#define INCLUDED_OPERATION
#include <taskchampion-cpp/lib.h>

View file

@ -33,13 +33,11 @@
#include <TDB2.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <stdlib.h>
#include <util.h>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>

View file

@ -27,7 +27,6 @@
#ifndef INCLUDED_TDB2
#define INCLUDED_TDB2
#include <FS.h>
#include <Task.h>
#include <taskchampion-cpp/lib.h>

View file

@ -31,7 +31,9 @@
#include <Table.h>
#include <cmake.h>
#include <format.h>
#include <main.h>
#ifdef PRODUCT_TASKWARRIOR
#include <legacy.h>
#endif
#include <shared.h>
#include <util.h>

View file

@ -58,7 +58,8 @@
#include <Eval.h>
#include <Filter.h>
#include <Variant.h>
#include <main.h>
#include <dependency.h>
#include <feedback.h>
#define APPROACHING_INFINITY 1000 // Close enough. This isn't rocket surgery.

View file

@ -28,7 +28,6 @@
#define INCLUDED_VARIANT
#include <Task.h>
#include <time.h>
#include <string>

View file

@ -30,7 +30,7 @@
#include <Context.h>
#include <ViewTask.h>
#include <format.h>
#include <main.h>
#include <rules.h>
#include <utf8.h>
#include <util.h>

View file

@ -30,13 +30,10 @@
#include <ColDepends.h>
#include <Context.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <stdlib.h>
#include <utf8.h>
#include <util.h>
#include <algorithm>
#include <regex>
#define STRING_COLUMN_LABEL_DEP "Depends"

View file

@ -32,8 +32,8 @@
#include <Eval.h>
#include <Filter.h>
#include <Variant.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <utf8.h>

View file

@ -29,8 +29,8 @@
#include <CmdAdd.h>
#include <Context.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
////////////////////////////////////////////////////////////////////////////////
CmdAdd::CmdAdd() {

View file

@ -30,8 +30,8 @@
#include <CmdAnnotate.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <iostream>

View file

@ -30,8 +30,8 @@
#include <CmdAppend.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <iostream>

View file

@ -33,7 +33,6 @@
#include <Duration.h>
#include <Filter.h>
#include <format.h>
#include <main.h>
#include <math.h>
#include <shared.h>
#include <string.h>

View file

@ -32,7 +32,6 @@
#include <Lexer.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <stdlib.h>
#include <utf8.h>

View file

@ -32,7 +32,6 @@
#include <Context.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <sstream>

View file

@ -31,7 +31,6 @@
#include <Color.h>
#include <Context.h>
#include <Table.h>
#include <main.h>
#include <shared.h>
#include <util.h>

View file

@ -33,7 +33,7 @@
#include <Filter.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <rules.h>
#include <shared.h>
#include <util.h>

View file

@ -30,7 +30,6 @@
#include <CmdCount.h>
#include <Filter.h>
#include <format.h>
#include <main.h>
////////////////////////////////////////////////////////////////////////////////
CmdCount::CmdCount() {

View file

@ -34,15 +34,15 @@
#include <Lexer.h>
#include <Version.h>
#include <ViewTask.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <legacy.h>
#include <shared.h>
#include <stdlib.h>
#include <sort.h>
#include <util.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>

View file

@ -30,8 +30,10 @@
#include <CmdDelete.h>
#include <Context.h>
#include <Filter.h>
#include <dependency.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <recur.h>
#include <shared.h>
#include <iostream>

View file

@ -30,8 +30,8 @@
#include <CmdDenotate.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <util.h>

View file

@ -30,8 +30,11 @@
#include <CmdDone.h>
#include <Context.h>
#include <Filter.h>
#include <dependency.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <nag.h>
#include <recur.h>
#include <util.h>
#include <iostream>

View file

@ -30,8 +30,8 @@
#include <CmdDuplicate.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <util.h>
#include <iostream>

View file

@ -36,7 +36,6 @@
#include <Lexer.h>
#include <Pig.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <unistd.h>
#include <util.h>

View file

@ -31,8 +31,9 @@
#include <Context.h>
#include <Filter.h>
#include <format.h>
#include <main.h>
#include <legacy.h>
#include <shared.h>
#include <sort.h>
////////////////////////////////////////////////////////////////////////////////
CmdExport::CmdExport() {

View file

@ -32,7 +32,6 @@
#include <DOM.h>
#include <Variant.h>
#include <format.h>
#include <main.h>
#include <shared.h>
////////////////////////////////////////////////////////////////////////////////

View file

@ -33,7 +33,6 @@
#include <Filter.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <util.h>
#include <sstream>

View file

@ -30,7 +30,6 @@
#include <CmdIDs.h>
#include <Context.h>
#include <Filter.h>
#include <main.h>
#include <shared.h>
#include <algorithm>

View file

@ -34,9 +34,9 @@
#include <Filter.h>
#include <Lexer.h>
#include <Operation.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <math.h>
#include <rules.h>
#include <shared.h>
#include <stdlib.h>
#include <taskchampion-cpp/lib.h>

View file

@ -29,8 +29,8 @@
#include <CmdLog.h>
#include <Context.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
////////////////////////////////////////////////////////////////////////////////
CmdLog::CmdLog() {

View file

@ -30,8 +30,9 @@
#include <CmdModify.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <recur.h>
#include <shared.h>
#include <iostream>

View file

@ -33,7 +33,6 @@
#include <Duration.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <util.h>

View file

@ -30,8 +30,8 @@
#include <CmdPrepend.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <iostream>

View file

@ -32,10 +32,9 @@
#include <Filter.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <sort.h>
#include <util.h>
#include <algorithm>
#include <list>
#include <sstream>

View file

@ -30,8 +30,8 @@
#include <CmdPurge.h>
#include <Context.h>
#include <Filter.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
////////////////////////////////////////////////////////////////////////////////

View file

@ -32,7 +32,7 @@
#include <FS.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <legacy.h>
#include <util.h>
#include <algorithm>

View file

@ -30,8 +30,11 @@
#include <CmdStart.h>
#include <Context.h>
#include <Filter.h>
#include <dependency.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <nag.h>
#include <recur.h>
#include <util.h>
#include <iostream>

View file

@ -34,7 +34,6 @@
#include <Filter.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <stdlib.h>
#include <util.h>

View file

@ -30,8 +30,10 @@
#include <CmdStop.h>
#include <Context.h>
#include <Filter.h>
#include <dependency.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <recur.h>
#include <iostream>

View file

@ -33,11 +33,10 @@
#include <Filter.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <sort.h>
#include <stdlib.h>
#include <util.h>
#include <algorithm>
#include <list>
#include <sstream>

View file

@ -33,8 +33,7 @@
#include <Filter.h>
#include <Table.h>
#include <format.h>
#include <main.h>
#include <stdlib.h>
#include <rules.h>
#include <util.h>
#include <algorithm>

View file

@ -33,7 +33,6 @@
#include <Table.h>
#include <Task.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <util.h>

View file

@ -31,12 +31,11 @@
#include <Context.h>
#include <Operation.h>
#include <Task.h>
#include <shared.h>
#include <iostream>
#include <sstream>
#include "shared.h"
////////////////////////////////////////////////////////////////////////////////
CmdUndo::CmdUndo() {
_keyword = "undo";

View file

@ -32,8 +32,6 @@
#include <Filter.h>
#include <Lexer.h>
#include <format.h>
#include <main.h>
#include <stdlib.h>
#include <sstream>

View file

@ -50,9 +50,7 @@
#include <CmdEdit.h>
#include <Command.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <stdlib.h>
#include <util.h>
#include <iostream>

View file

@ -28,8 +28,8 @@
// cmake.h include header must come first
#include <Context.h>
#include <dependency.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <iostream>

43
src/dependency.h Normal file
View file

@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_DEPENDENCY
#define INCLUDED_DEPENDENCY
#include <cmake.h>
// cmake.h include header must come first
#include <Task.h>
#define STRING_DEPEND_BLOCKED "Task {1} is blocked by:"
bool dependencyIsCircular(const Task& task);
void dependencyChainOnComplete(Task& task);
void dependencyChainOnStart(Task& task);
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -31,8 +31,8 @@
#include <Datetime.h>
#include <Duration.h>
#include <Lexer.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <shared.h>
#include <stdlib.h>

54
src/feedback.h Normal file
View file

@ -0,0 +1,54 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_FEEDBACK
#define INCLUDED_FEEDBACK
#include <cmake.h>
// cmake.h include header must come first
#include <Task.h>
#include <string>
#include <vector>
std::string renderAttribute(const std::string& name, const std::string& value,
const std::string& format = "");
void feedback_affected(const std::string& effect);
void feedback_affected(const std::string& effect, int quantity);
void feedback_affected(const std::string& effect, const Task& task);
void feedback_reserved_tags(const std::string& tag);
void feedback_special_tags(const Task& task, const std::string& tag);
void feedback_unblocked(const Task& task);
void feedback_backlog();
std::string onProjectChange(Task& task, bool scope = true);
std::string onProjectChange(Task& task1, Task& task2);
std::string onExpiration(Task& task);
#endif
////////////////////////////////////////////////////////////////////////////////

44
src/legacy.h Normal file
View file

@ -0,0 +1,44 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_LEGACY
#define INCLUDED_LEGACY
#include <cmake.h>
// cmake.h include header must come first
#include <string>
void legacyColumnMap(std::string& name);
void legacySortColumnMap(std::string& name);
std::string legacyCheckForDeprecatedVariables();
std::string legacyCheckForDeprecatedColumns();
void legacyAttributeMap(std::string& name);
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -1,93 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN
#include <Color.h>
#include <Context.h>
#include <Datetime.h>
#include <sys/types.h>
#include <list>
#include <map>
#include <optional>
#include <string>
#include <vector>
// recur.cpp
void handleRecurrence();
void handleUntil();
std::optional<Datetime> checked_add_datetime(Datetime& base, time_t delta);
std::optional<Datetime> getNextRecurrence(Datetime&, std::string&);
bool generateDueDates(Task&, std::vector<Datetime>&);
void updateRecurrenceMask(Task&);
// nag.cpp
void nag(std::vector<Task>&);
// rules.cpp
void initializeColorRules();
void autoColorize(Task&, Color&);
std::string colorizeHeader(const std::string&);
std::string colorizeFootnote(const std::string&);
std::string colorizeError(const std::string&);
std::string colorizeDebug(const std::string&);
// dependency.cpp
bool dependencyIsCircular(const Task&);
void dependencyChainOnComplete(Task&);
void dependencyChainOnStart(Task&);
// feedback.cpp
std::string renderAttribute(const std::string&, const std::string&, const std::string& format = "");
void feedback_affected(const std::string&);
void feedback_affected(const std::string&, int);
void feedback_affected(const std::string&, const Task&);
void feedback_reserved_tags(const std::string&);
void feedback_special_tags(const Task&, const std::string&);
void feedback_unblocked(const Task&);
void feedback_backlog();
std::string onProjectChange(Task&, bool scope = true);
std::string onProjectChange(Task&, Task&);
std::string onExpiration(Task&);
// sort.cpp
void sort_tasks(std::vector<Task>&, std::vector<int>&, const std::string&);
void sort_projects(std::list<std::pair<std::string, int>>& sorted,
std::map<std::string, int>& allProjects);
void sort_projects(std::list<std::pair<std::string, int>>& sorted,
std::map<std::string, bool>& allProjects);
// legacy.cpp
void legacyColumnMap(std::string&);
void legacySortColumnMap(std::string&);
std::string legacyCheckForDeprecatedVariables();
std::string legacyCheckForDeprecatedColumns();
void legacyAttributeMap(std::string&);
#endif
////////////////////////////////////////////////////////////////////////////////

43
src/nag.h Normal file
View file

@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_NAG
#define INCLUDED_NAG
#include <cmake.h>
// cmake.h include header must come first
#include <Task.h>
#include <vector>
////////////////////////////////////////////////////////////////////////////////
// Generates a nag message when there are READY tasks of a higher urgency.
void nag(std::vector<Task>& tasks);
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -31,9 +31,10 @@
#include <Datetime.h>
#include <Duration.h>
#include <Lexer.h>
#include <feedback.h>
#include <format.h>
#include <main.h>
#include <pwd.h>
#include <recur.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>

57
src/recur.h Normal file
View file

@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_RECUR
#define INCLUDED_RECUR
#include <cmake.h>
// cmake.h include header must come first
#include <Context.h>
#include <Datetime.h>
#include <Duration.h>
#include <Lexer.h>
#include <format.h>
#include <pwd.h>
#include <sys/types.h>
#include <time.h>
#include <unicode.h>
#include <unistd.h>
#include <util.h>
#include <optional>
std::optional<Datetime> checked_add_datetime(Datetime& base, time_t delta);
void handleRecurrence();
bool generateDueDates(Task& parent, std::vector<Datetime>& allDue);
std::optional<Datetime> getNextRecurrence(Datetime& current, std::string& period);
void updateRecurrenceMask(Task& task);
void handleUntil();
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -29,7 +29,7 @@
#include <Context.h>
#include <Datetime.h>
#include <main.h>
#include <rules.h>
#include <shared.h>
static std::map<std::string, Color> gsColor;

47
src/rules.h Normal file
View file

@ -0,0 +1,47 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_RULES
#define INCLUDED_RULES
#include <cmake.h>
// cmake.h include header must come first
#include <Context.h>
#include <Datetime.h>
#include <shared.h>
void initializeColorRules();
void autoColorize(Task& task, Color& c);
std::string colorizeHeader(const std::string& input);
std::string colorizeFootnote(const std::string& input);
std::string colorizeError(const std::string& input);
std::string colorizeDebug(const std::string& input);
#endif
////////////////////////////////////////////////////////////////////////////////

51
src/sort.h Normal file
View file

@ -0,0 +1,51 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2025, Tomas Babej, Paul Beckingham, Federico Hernandez,
// Tobias Predel.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// https://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_SORT
#define INCLUDED_SORT
#include <cmake.h>
// cmake.h include header must come first
#include <Task.h>
#include <list>
#include <map>
#include <string>
#include <vector>
void sort_tasks(std::vector<Task>& data, std::vector<int>& order, const std::string& keys);
void sort_projects(std::list<std::pair<std::string, int>>& sorted,
std::map<std::string, int>& allProjects);
void sort_projects(std::list<std::pair<std::string, int>>& sorted,
std::map<std::string, bool>& allProjects);
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -34,8 +34,8 @@
#ifdef FREEBSD
#define _WITH_GETLINE
#endif
#include <Context.h>
#include <Lexer.h>
#include <main.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>

View file

@ -28,8 +28,6 @@
// cmake.h include header must come first
#include <columns/ColID.h>
#include <main.h>
#include <stdlib.h>
#include <test.h>
////////////////////////////////////////////////////////////////////////////////

View file

@ -28,16 +28,12 @@
// cmake.h include header must come first
#include <CmdInfo.h>
#include <main.h>
#include <stdlib.h>
#include <taskchampion-cpp/lib.h>
#include <test.h>
#include <util.h>
#include <iostream>
#include <limits>
#include "format.h"
namespace {

View file

@ -27,10 +27,11 @@
#include <cmake.h>
// cmake.h include header must come first
#include <main.h>
#include <stdlib.h>
#include <test.h>
#include "Context.h"
////////////////////////////////////////////////////////////////////////////////
int TEST_NAME(int, char**) {
UnitTest test(48);

View file

@ -27,12 +27,10 @@
#include <cmake.h>
// cmake.h include header must come first
#include <main.h>
#include <stdlib.h>
#include <test.h>
#include <unistd.h>
#include <iostream>
#include "Context.h"
namespace {

View file

@ -26,11 +26,9 @@
#include <cmake.h>
#include <iostream>
// cmake.h include header must come first
#include <main.h>
#include <stdlib.h>
#include <Task.h>
#include <test.h>
////////////////////////////////////////////////////////////////////////////////

View file

@ -27,12 +27,11 @@
#include <cmake.h>
// cmake.h include header must come first
#include <main.h>
#include <stdlib.h>
#include <Context.h>
#include <recur.h>
#include <test.h>
#include <util.h>
#include <iostream>
#include <limits>
////////////////////////////////////////////////////////////////////////////////

View file

@ -31,9 +31,8 @@
#include <Context.h>
#include <Task.h>
#include <ViewTask.h>
#include <main.h>
#include <sort.h>
#include <stdio.h>
#include <stdlib.h>
#include <test.h>
#include <unistd.h>