DOM: New references: tw.syncneeded, tw.program, tw.args, tw.width, tw.height

- And deprecating context.program, context.args, context.width, context.height
This commit is contained in:
Paul Beckingham 2017-02-25 19:21:24 -05:00
parent 6641ca13a1
commit 3a69609ffd
4 changed files with 87 additions and 10 deletions

View file

@ -88,6 +88,7 @@
- Added 'history.weekly', 'history.daily', 'ghistory.weekly', 'ghistory.daily' - Added 'history.weekly', 'history.daily', 'ghistory.weekly', 'ghistory.daily'
report variations, with code refactoring. report variations, with code refactoring.
(thanks to Lukas Barth). (thanks to Lukas Barth).
- New DOM references: annotations.count, tw.syncneeded.
------ current release --------------------------- ------ current release ---------------------------

6
NEWS
View file

@ -5,7 +5,8 @@ New Features in Taskwarrior 2.5.2
- The 'help' command now takes a 'usage' argument, which displays only the - The 'help' command now takes a 'usage' argument, which displays only the
command usage. command usage.
- Improved compatibility with SmartOS, OmniOS and OpenIndiana. - Improved compatibility with SmartOS, OmniOS and OpenIndiana.
- New DOM reference: annotations.count. - New DOM references: annotations.count, tw.syncneeded, tw.program, tw.args,
tw.width, tw.height.
- Renovated 'timesheet' command with a more compact report that accepts a - Renovated 'timesheet' command with a more compact report that accepts a
filter, and has a default filter showing the last four weeks of completed filter, and has a default filter showing the last four weeks of completed
and started tasks. and started tasks.
@ -33,6 +34,9 @@ Newly Deprecated Features in Taskwarrior 2.5.2
- The use of alternate Boolean configuration settings is deprecated. Use values - The use of alternate Boolean configuration settings is deprecated. Use values
"0" for off, and "1" for on. Avoid used of "on", "off", "true", "t", "0" for off, and "1" for on. Avoid used of "on", "off", "true", "t",
"false", "f", "yes", "y", "no", "n". "false", "f", "yes", "y", "no", "n".
- The 'context.program', 'context.args', 'context.width' and 'context.height'
DOM references are deprecated, replaced by similarly-named 'tw.xxx'
references.
Removed Features in 2.5.2 Removed Features in 2.5.2

View file

@ -47,11 +47,18 @@ extern Context context;
// Configuration: // Configuration:
// rc.<name> // rc.<name>
// //
// Taskwarrior:
// tw.syncneeded
// tw.program
// tw.args
// tw.width
// tw.height
//
// System: // System:
// context.program // context.program // 2017-02-25 Deprecated in 2.6.0
// context.args // context.args // 2017-02-25 Deprecated in 2.6.0
// context.width // context.width // 2017-02-25 Deprecated in 2.6.0
// context.height // context.height // 2017-02-25 Deprecated in 2.6.0
// system.version // system.version
// system.os // system.os
// //
@ -78,6 +85,61 @@ bool getDOM (const std::string& name, Variant& value)
return false; return false;
} }
// tw.*
if (len > 3 &&
! name.compare (0, 3, "tw.", 3))
{
if (name == "tw.syncneeded")
{
value = Variant (false);
for (const auto& line : context.tdb2.backlog.get_lines ())
{
if (line[0] == '{')
{
value = Variant (true);
break;
}
}
return true;
}
else if (name == "tw.program")
{
value = Variant (context.cli2.getBinary ());
return true;
}
else if (name == "tw.args")
{
std::string commandLine;
for (auto& arg : context.cli2._original_args)
{
if (commandLine != "")
commandLine += ' ';
commandLine += arg.attribute("raw");
}
value = Variant (commandLine);
return true;
}
else if (name == "tw.width")
{
value = Variant (static_cast<int> (context.terminal_width
? context.terminal_width
: context.getWidth ()));
return true;
}
else if (name == "tw.height")
{
value = Variant (static_cast<int> (context.terminal_height
? context.terminal_height
: context.getHeight ()));
return true;
}
else
throw format (STRING_DOM_UNREC, name);
}
// context.* // context.*
if (len > 8 && if (len > 8 &&
! name.compare (0, 8, "context.", 8)) ! name.compare (0, 8, "context.", 8))

View file

@ -1132,10 +1132,15 @@ bool Lexer::isOperator (std::string& token, Lexer::Type& type)
// rc.<name> // rc.<name>
// //
// System: // System:
// context.program // tw.syncneeded
// context.args // tw.program
// context.width // tw.args
// context.height // tw.width
// tw.height
// context.program // 2017-02-25 Deprecated in 2.6.0
// context.args // 2017-02-25 Deprecated in 2.6.0
// context.width // 2017-02-25 Deprecated in 2.6.0
// context.height // 2017-02-25 Deprecated in 2.6.0
// system.version // system.version
// system.os // system.os
// //
@ -1179,7 +1184,12 @@ bool Lexer::isDOM (std::string& token, Lexer::Type& type)
else else
_cursor = marker; _cursor = marker;
if (isOneOf ({"context.program", if (isOneOf ({"tw.syncneeded",
"tw.program",
"tw.args",
"tw.width",
"tw.height",
"context.program",
"context.args", "context.args",
"context.width", "context.width",
"context.height", "context.height",