mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Add hint :annotations to display annotation column in summary (default: hidden)
This commit is contained in:
parent
a35b9d6660
commit
3678c2cdc3
2 changed files with 33 additions and 13 deletions
|
@ -82,6 +82,7 @@ int CmdSummary (
|
||||||
Color colorID (rules.getBoolean ("color") ? rules.get ("theme.colors.ids") : "");
|
Color colorID (rules.getBoolean ("color") ? rules.get ("theme.colors.ids") : "");
|
||||||
|
|
||||||
auto ids = findHint (cli, ":ids");
|
auto ids = findHint (cli, ":ids");
|
||||||
|
auto show_annotation = findHint (cli, ":annotations");
|
||||||
|
|
||||||
Table table;
|
Table table;
|
||||||
table.width (1024);
|
table.width (1024);
|
||||||
|
@ -91,10 +92,20 @@ int CmdSummary (
|
||||||
table.add ("Day");
|
table.add ("Day");
|
||||||
|
|
||||||
if (ids)
|
if (ids)
|
||||||
|
{
|
||||||
table.add ("ID");
|
table.add ("ID");
|
||||||
|
}
|
||||||
|
|
||||||
table.add ("Tags");
|
table.add ("Tags");
|
||||||
|
|
||||||
|
auto offset = 0;
|
||||||
|
|
||||||
|
if (show_annotation)
|
||||||
|
{
|
||||||
table.add ("Annotation");
|
table.add ("Annotation");
|
||||||
|
offset = 1;
|
||||||
|
}
|
||||||
|
|
||||||
table.add ("Start", false);
|
table.add ("Start", false);
|
||||||
table.add ("End", false);
|
table.add ("End", false);
|
||||||
table.add ("Time", false);
|
table.add ("Time", false);
|
||||||
|
@ -131,32 +142,40 @@ int CmdSummary (
|
||||||
today.end = Datetime ();
|
today.end = Datetime ();
|
||||||
|
|
||||||
std::string tags = join(", ", track.tags());
|
std::string tags = join(", ", track.tags());
|
||||||
|
|
||||||
|
if (ids)
|
||||||
|
{
|
||||||
|
table.set (row, 3, format ("@{1}", track.id), colorID);
|
||||||
|
}
|
||||||
|
|
||||||
|
table.set (row, (ids ? 4 : 3), tags);
|
||||||
|
|
||||||
|
if (show_annotation)
|
||||||
|
{
|
||||||
auto annotation = track.getAnnotation ();
|
auto annotation = track.getAnnotation ();
|
||||||
|
|
||||||
if (annotation.length () > 15)
|
if (annotation.length () > 15)
|
||||||
annotation = annotation.substr (0, 12) + "...";
|
annotation = annotation.substr (0, 12) + "...";
|
||||||
|
|
||||||
if (ids)
|
|
||||||
table.set (row, 3, format ("@{1}", track.id), colorID);
|
|
||||||
|
|
||||||
table.set (row, (ids ? 4 : 3), tags);
|
|
||||||
table.set (row, (ids ? 5 : 4), annotation);
|
table.set (row, (ids ? 5 : 4), annotation);
|
||||||
table.set (row, (ids ? 6 : 5), today.start.toString ("h:N:S"));
|
}
|
||||||
table.set (row, (ids ? 7 : 6), (track.is_open () ? "-" : today.end.toString ("h:N:S")));
|
|
||||||
table.set (row, (ids ? 8 : 7), Duration (today.total ()).formatHours ());
|
table.set (row, (ids ? 5 : 4) + offset, today.start.toString ("h:N:S"));
|
||||||
|
table.set (row, (ids ? 6 : 5) + offset, (track.is_open () ? "-" : today.end.toString ("h:N:S")));
|
||||||
|
table.set (row, (ids ? 7 : 6) + offset, Duration (today.total ()).formatHours ());
|
||||||
|
|
||||||
daily_total += today.total ();
|
daily_total += today.total ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row != -1)
|
if (row != -1)
|
||||||
table.set (row, (ids ? 9 : 8), Duration (daily_total).formatHours ());
|
table.set (row, (ids ? 8 : 7) + offset, Duration (daily_total).formatHours ());
|
||||||
|
|
||||||
grand_total += daily_total;
|
grand_total += daily_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the total.
|
// Add the total.
|
||||||
table.set (table.addRow (), (ids ? 9 : 8), " ", Color ("underline"));
|
table.set (table.addRow (), (ids ? 8 : 7) + offset, " ", Color ("underline"));
|
||||||
table.set (table.addRow (), (ids ? 9 : 8), Duration (grand_total).formatHours ());
|
table.set (table.addRow (), (ids ? 8 : 7) + offset, Duration (grand_total).formatHours ());
|
||||||
|
|
||||||
std::cout << '\n'
|
std::cout << '\n'
|
||||||
<< table.render ()
|
<< table.render ()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
// Copyright 2016 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -93,6 +93,7 @@ void initializeEntities (CLI& cli)
|
||||||
cli.entity ("hint", ":debug");
|
cli.entity ("hint", ":debug");
|
||||||
cli.entity ("hint", ":fill");
|
cli.entity ("hint", ":fill");
|
||||||
cli.entity ("hint", ":ids");
|
cli.entity ("hint", ":ids");
|
||||||
|
cli.entity ("hint", ":annotations");
|
||||||
cli.entity ("hint", ":lastmonth");
|
cli.entity ("hint", ":lastmonth");
|
||||||
cli.entity ("hint", ":lastquarter");
|
cli.entity ("hint", ":lastquarter");
|
||||||
cli.entity ("hint", ":lastweek");
|
cli.entity ("hint", ":lastweek");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue