mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Allow specification of intervals to the export command
This patch checks if intervals are given on cli to 'timew export', and if so will filter only those numbered IDs out from the db. This lets the user that already knows the interval(s) they want to know about, to ask for only those, without parsing the whole thing (similar to how we can do this for taskwarrior IDs). If both intervals and other filters -- time range or tags -- are given, this is considered an error. There would seem to be little use to AND or OR tags/ranges with IDs because anyone that knew IDs to request would already know those IDs met their requirement. Fixes #510 Code additions from @lauft PR notes (thanks!): - factor out 'filtering' so we can do only one call to getTracked() - simplify (tag || range) to .empty(), which already checks both - error message phrasing Signed-off-by: Scott Mcdermott <scott@smemsh.net>
This commit is contained in:
parent
e708a63612
commit
bf26176243
3 changed files with 37 additions and 9 deletions
|
@ -48,6 +48,17 @@ class TestExport(TestCase):
|
|||
code, out, err = self.t("export")
|
||||
self.assertIn("[\n]\n", out)
|
||||
|
||||
def test_fixed_id_export(self):
|
||||
"""Give specific IDs on CLI"""
|
||||
self.t("track 2022-12-10T00:00:00Z - 2022-12-10T01:00:00Z")
|
||||
self.t("track 2022-12-10T01:00:00Z - 2022-12-10T02:00:00Z")
|
||||
self.t("track 2022-12-10T02:00:00Z - 2022-12-10T03:00:00Z")
|
||||
self.t("track 2022-12-10T04:00:00Z - 2022-12-10T05:00:00Z")
|
||||
j = self.t.export("@1 @4")
|
||||
self.assertEqual(len(j), 2)
|
||||
self.assertClosedInterval(j[0], expectedStart="20221210T000000Z", expectedId=4)
|
||||
self.assertClosedInterval(j[1], expectedStart="20221210T040000Z", expectedId=1)
|
||||
|
||||
def test_single_unobstructed_interval(self):
|
||||
"""Single unobstructed interval"""
|
||||
now_utc = datetime.now().utcnow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue