Add hint :all

- Closes #206

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Thomas Lauf 2020-06-03 17:59:11 +02:00
parent 6117ce1a84
commit c9eec956e4
3 changed files with 27 additions and 5 deletions

View file

@ -664,12 +664,19 @@ Interval CLI::getFilter (const Range& default_range) const
Range range;
if (expandIntervalHint (canonical, range))
{
start = range.start.toISO ();
end = range.end.toISO ();
if (range.is_empty ())
{
args.push_back ("<all>");
}
else
{
start = range.start.toISO ();
end = range.end.toISO ();
args.push_back ("<date>");
args.push_back ("-");
args.push_back ("<date>");
args.push_back ("<date>");
args.push_back ("-");
args.push_back ("<date>");
}
}
// Hints that are not expandable to a date range are ignored.
@ -807,6 +814,12 @@ Interval CLI::getFilter (const Range& default_range) const
filter.setRange ({now - Duration (duration).toTime_t (), now});
}
// :all
else if (args.size () == 1 && args[0] == "<all>")
{
filter.setRange (0, 0);
}
// Unrecognized date range construct.
else if (! args.empty ())
{

View file

@ -176,6 +176,14 @@ bool expandIntervalHint (
return true;
}
if (hint == ":all")
{
range.start = 0;
range.end = 0;
return true;
}
// Some require math.
if (hint == ":lastweek")
{

View file

@ -88,6 +88,7 @@ void initializeEntities (CLI& cli)
cli.entity ("extension", "week");
// Hint entities.
cli.entity ("hint", ":all");
cli.entity ("hint", ":adjust");
cli.entity ("hint", ":blank");
cli.entity ("hint", ":color");