mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdTags: Renders results in a table
- Obeys tags.<tag>.color and tags.<tag>.description.
This commit is contained in:
parent
894e62a6b0
commit
5ad8a6869a
1 changed files with 25 additions and 5 deletions
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <commands.h>
|
#include <commands.h>
|
||||||
|
#include <Table.h>
|
||||||
|
#include <Color.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -39,14 +41,32 @@ int CmdTags (Rules& rules, Database& database, Log& log)
|
||||||
if (std::find (tags.begin (), tags.end (), tag) == tags.end ())
|
if (std::find (tags.begin (), tags.end (), tag) == tags.end ())
|
||||||
tags.push_back (tag);
|
tags.push_back (tag);
|
||||||
|
|
||||||
// TODO Determine sort order - most recent first?
|
|
||||||
// TODO Determine sort order - most common first?
|
|
||||||
|
|
||||||
// Shows all tags.
|
// Shows all tags.
|
||||||
|
Table t;
|
||||||
|
t.width (1024);
|
||||||
|
t.colorHeader (Color ("underline"));
|
||||||
|
t.add ("Tag");
|
||||||
|
t.add ("Description");
|
||||||
// TODO Show all tag metadata.
|
// TODO Show all tag metadata.
|
||||||
for (auto& tag : tags)
|
|
||||||
std::cout << tag << "\n";
|
|
||||||
|
|
||||||
|
for (auto& tag : tags)
|
||||||
|
{
|
||||||
|
auto row = t.addRow ();
|
||||||
|
|
||||||
|
Color c;
|
||||||
|
std::string name = std::string ("tag.") + tag + ".color";
|
||||||
|
if (rules.has (name))
|
||||||
|
c = Color (rules.get (name));
|
||||||
|
|
||||||
|
t.set (row, 0, tag, c);
|
||||||
|
|
||||||
|
name = std::string ("tag.") + tag + ".description";
|
||||||
|
t.set (row, 1, rules.get (name));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\n"
|
||||||
|
<< t.render ()
|
||||||
|
<< "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue