mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Task: Dependencies are exported as a JSON array
- The 'json.depends.array' setting controls whether dedendencies are encoded as a JSON array, or comma-separated string. - The default value is on. - Both forms are imported.
This commit is contained in:
parent
caab26247c
commit
0f4d3c1d60
6 changed files with 46 additions and 0 deletions
|
@ -110,6 +110,8 @@
|
|||
- Commands that do not accept filters or modifications now generate an error
|
||||
when extra arguments are specified.
|
||||
- Improved zsh support (thanks to Daniel Shahaf).
|
||||
- Dependencies are exported as a JSON array by default, overridable using
|
||||
'rc.json.depends.array=off'. Both forms are imported.
|
||||
|
||||
------ current release ---------------------------
|
||||
|
||||
|
|
4
NEWS
4
NEWS
|
@ -12,6 +12,10 @@ New commands in Taskwarrior 2.4.5
|
|||
|
||||
New configuration options in Taskwarrior 2.4.5
|
||||
|
||||
- The 'json.depends.array' setting controls whether dependencies are exported
|
||||
as a JSON array, of a comma-separated string. Default is 'on'.
|
||||
Both variations are imported.
|
||||
|
||||
Newly deprecated features in Taskwarrior 2.4.5
|
||||
|
||||
- The '_ids', '_projects', '_tags', '_uuids' helper commands are deprecated,
|
||||
|
|
|
@ -401,6 +401,12 @@ array.
|
|||
With json.array=off, export writes raw JSON objects to STDOUT, one per line.
|
||||
Defaults to on.
|
||||
|
||||
.TP
|
||||
.B json.depends.array=on
|
||||
Determines whether the export command encodes dependencies as an array of string
|
||||
UUIDs, or one comma-separated string.
|
||||
Defaults to on.
|
||||
|
||||
.TP
|
||||
.B _forcecolor=no
|
||||
Taskwarrior shuts off color automatically when the output is not sent directly
|
||||
|
|
|
@ -107,6 +107,7 @@ std::string Config::_defaults =
|
|||
"expressions=infix # Prefer infix over postfix expressions\n"
|
||||
"dom=on # Support DOM access\n"
|
||||
"json.array=on # Enclose JSON output in [ ]\n"
|
||||
"json.depends.array=on # Encode dependencies as a JSON array\n"
|
||||
"abbreviation.minimum=2 # Shortest allowed abbreviation\n"
|
||||
"\n"
|
||||
"# Dates\n"
|
||||
|
|
32
src/Task.cpp
32
src/Task.cpp
|
@ -694,6 +694,18 @@ void Task::parseJSON (const json::object* root_obj)
|
|||
addTag (tag->_data);
|
||||
}
|
||||
|
||||
// Dependencies can be exported as a single comma-separated string, or as
|
||||
// an array of strings.
|
||||
else if (i.first == "depends" && i.second->type() == json::j_array)
|
||||
{
|
||||
json::array* tags = (json::array*)i.second;
|
||||
for (auto& t : tags->_data)
|
||||
{
|
||||
json::string* tag = (json::string*)t;
|
||||
addDependency (tag->_data);
|
||||
}
|
||||
}
|
||||
|
||||
// Strings are decoded.
|
||||
else if (type == "string")
|
||||
set (i.first, json::decode (unquoteText (i.second->dump ())));
|
||||
|
@ -887,7 +899,27 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
|||
}
|
||||
|
||||
out << "]";
|
||||
++attributes_written;
|
||||
}
|
||||
|
||||
// Dependencies are an array by default.
|
||||
else if (i.first == "depends" &&
|
||||
context.config.getBoolean ("json.depends.array"))
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
split (deps, i.second, ',');
|
||||
|
||||
out << "\"depends\":[";
|
||||
|
||||
for (auto i = deps.begin (); i != deps.end (); ++i)
|
||||
{
|
||||
if (i != deps.begin ())
|
||||
out << ",";
|
||||
|
||||
out << "\"" << *i << "\"";
|
||||
}
|
||||
|
||||
out << "]";
|
||||
++attributes_written;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ int CmdShow::execute (std::string& output)
|
|||
" journal.time.start.annotation"
|
||||
" journal.time.stop.annotation"
|
||||
" json.array"
|
||||
" json.depends.array"
|
||||
" list.all.projects"
|
||||
" list.all.tags"
|
||||
" locking"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue