cirocosta / asciinema-edit

asciinema casts post-production tools
https://ops.tips
MIT License
316 stars 22 forks source link

Validates cast before applying transformation #12

Closed cirocosta closed 6 years ago

cirocosta commented 6 years ago
commit 9c7070106010c7335b2090fda67bd133a04351e9

    Adds input cast validation to `transformer`

    Whenever a cast is consumed from `transformer`, a cast validation is now
    performed.

    This commit makes even more natural to develop the commands as the developer
    doesn't need to worry about receiving invalid casts.

    Naturally, that's the expectation - there might exist a case when a
    a command could potentially *want* to receive an invalid cast (which is
    not the situation right now).

Example

diff --git a/fixture/test.cast b/fixture/test.cast
index 450cd5b..35d9622 100644
--- a/fixture/test.cast
+++ b/fixture/test.cast
@@ -6,6 +6,7 @@
 [0.71805, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;32m \u001b[36masciinema-edit \u001b[01;34m(\u001b[31mmaster\u001b[34m) \u001b[33m✗\u001b[00m\u001b[00m\u001b[01;34m \u001b[00m\u001b[K"]
 [0.71837, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
 [2.180143, "o", "h"]
+[3.491024, "o", "a"]
 [2.251254, "o", "\bhe"]
 [2.323189, "o", "y"]
 [2.578577, "o", "\u001b[?1l\u001b>"]
@@ -27,7 +28,6 @@
 [3.195158, "o", "i"]
 [3.307171, "o", "s"]
 [3.37903, "o", " "]
-[3.491024, "o", "a"]
 [3.578843, "o", " "]
 [4.194759, "o", "\b"]
 [4.328254, "o", "\b \b"]
./asciinema-edit speed --factor=1 ./fixture/test.cast 
invalid input cast: invalid event stream: events must be ordered by time

(before it wouldn't produce an early fail)

11

cirocosta commented 6 years ago

cc @henvic