mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TW-1881: default.scheduled seems not to work
- Thanks to Onion.
This commit is contained in:
parent
a60c373caf
commit
5ff5a5c1ae
9 changed files with 42 additions and 6 deletions
|
@ -249,6 +249,7 @@ std::string Config::_defaults =
|
|||
"\n"
|
||||
"#default.project=foo # Default project for 'add' command\n"
|
||||
"#default.due=eom # Default due date for 'add' command\n"
|
||||
"#default.scheduled=eom # Default scheduled date for 'add' command\n"
|
||||
"default.command=next # When no arguments are specified\n"
|
||||
"\n"
|
||||
"_forcecolor=0 # Forces color to be on, even for non TTY output\n"
|
||||
|
|
|
@ -686,6 +686,7 @@ void Context::staticInitialization ()
|
|||
|
||||
Task::defaultProject = config.get ("default.project");
|
||||
Task::defaultDue = config.get ("default.due");
|
||||
Task::defaultScheduled = config.get ("default.scheduled");
|
||||
|
||||
Task::searchCaseSensitive = Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
||||
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||
|
|
28
src/Task.cpp
28
src/Task.cpp
|
@ -67,10 +67,11 @@ extern Task& contextTask;
|
|||
static const float epsilon = 0.000001;
|
||||
#endif
|
||||
|
||||
std::string Task::defaultProject = "";
|
||||
std::string Task::defaultDue = "";
|
||||
bool Task::searchCaseSensitive = true;
|
||||
bool Task::regex = false;
|
||||
std::string Task::defaultProject = "";
|
||||
std::string Task::defaultDue = "";
|
||||
std::string Task::defaultScheduled = "";
|
||||
bool Task::searchCaseSensitive = true;
|
||||
bool Task::regex = false;
|
||||
std::map <std::string, std::string> Task::attributes;
|
||||
|
||||
std::map <std::string, float> Task::coefficients;
|
||||
|
@ -1565,6 +1566,20 @@ void Task::validate (bool applyDefault /* = true */)
|
|||
}
|
||||
}
|
||||
|
||||
// Override with default.scheduled, if not specified.
|
||||
if (Task::defaultScheduled != "" &&
|
||||
! has ("scheduled"))
|
||||
{
|
||||
if (context.columns["scheduled"]->validate (Task::defaultScheduled))
|
||||
{
|
||||
Duration dur (Task::defaultScheduled);
|
||||
if (dur.toTime_t () != 0)
|
||||
set ("scheduled", (Datetime () + dur.toTime_t ()).toEpoch ());
|
||||
else
|
||||
set ("scheduled", Datetime (Task::defaultScheduled).toEpoch ());
|
||||
}
|
||||
}
|
||||
|
||||
// If a UDA has a default value in the configuration,
|
||||
// override with uda.(uda).default, if not specified.
|
||||
// Gather a list of all UDAs with a .default value
|
||||
|
@ -2044,8 +2059,9 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||
// ::composeF4 will skip if the value is blank, but the presence of
|
||||
// the attribute will prevent ::validate from applying defaults.
|
||||
if ((has (name) && get (name) != "") ||
|
||||
(name == "due" && context.config.has ("default.due")) ||
|
||||
(name == "project" && context.config.has ("default.project")))
|
||||
(name == "due" && context.config.has ("default.due")) ||
|
||||
(name == "scheduled" && context.config.has ("default.scheduled")) ||
|
||||
(name == "project" && context.config.has ("default.project")))
|
||||
{
|
||||
mods = true;
|
||||
set (name, "");
|
||||
|
|
|
@ -39,6 +39,7 @@ class Task
|
|||
public:
|
||||
static std::string defaultProject;
|
||||
static std::string defaultDue;
|
||||
static std::string defaultScheduled;
|
||||
static bool searchCaseSensitive;
|
||||
static bool regex;
|
||||
static std::map <std::string, std::string> attributes; // name -> type
|
||||
|
|
|
@ -144,6 +144,7 @@ int CmdShow::execute (std::string& output)
|
|||
" default.command"
|
||||
" default.due"
|
||||
" default.project"
|
||||
" default.scheduled"
|
||||
" defaultheight"
|
||||
" defaultwidth"
|
||||
" dependency.confirmation"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue