Support selecting time ranges
[tt.git] / tt.rkt
diff --git a/tt.rkt b/tt.rkt
index afc94f6..9a38136 100644 (file)
--- a/tt.rkt
+++ b/tt.rkt
                (exit 1)))]
         [(or "r" "read")
          (let ([out-format 'multi-line]
-               [order      'old->new])
+               [order      'old->new]
+               [ts-min     #f]
+               [ts-max     #f])
            (command-line
              #:program
              "tt read"
              [("-r" "--rev")
               "Reverse displayed timeline order."
               (set! order 'new->old)]
+             [("-m" "--min")
+              m "Earliest time to display (ignore anything before it)."
+              (set! ts-min (rfc3339->epoch m))]
+             [("-x" "--max")
+              x "Latest time to display (ignore anything after it)."
+              (set! ts-max (rfc3339->epoch x))]
              #:once-any
              [("-s" "--short")
               "Short output format"
              (let* ([peers
                       (paths->peers file-paths)]
                     [timeline
-                      (timeline-sort (peers->timeline peers) order)])
+                      (timeline-sort (peers->timeline peers) order)]
+                    [timeline
+                      (filter (λ (m) (and (if ts-min (>= (Msg-ts-epoch m)
+                                                         ts-min)
+                                              #t)
+                                          (if ts-max (<= (Msg-ts-epoch m)
+                                                         ts-max)
+                                              #t)))
+                              timeline)])
                (timeline-print out-format timeline))))]
         [(or "c" "crawl")
          (command-line
This page took 0.02978 seconds and 4 git commands to generate.