Render sequence diagrams as terminal text: a small DSL, a layout engine, and a CLI.
┌────────┐ ┌────────┐
│ Client │ │ Server │
└────┬───┘ └────┬───┘
│ ping │
│────────────>│
│ pong │
│┄┄┄┄┄┄┄┄┄┄┄┄>│
│ │moon add LMK-ai-nb/seqdrawmoon run cmd/main -- examples/login.seq| Line | Meaning |
|---|---|
| participant A as Client | declare a column; the label is optional and defaults to the id |
| A -> B: text | solid arrow with a filled head |
| A --> B: text | dashed arrow |
| A ->> B: text | solid arrow with an open head |
| A -->> B: text | dashed arrow with an open head |
| A -> A: text | self message, drawn as a loop |
| note over A: text | note box over one column |
| note over A,B: text | note box spanning two columns |
| alt label / else label / end | conditional block |
| loop label / end | repeated block |
| opt label / end | optional block |
match @seqdraw.parse(source) {
Err(err) => println(err.to_text())
Ok(diagram) => println(@seqdraw.render(diagram))
}| File | Shows |
|---|---|
| examples/login.seq | three columns, a conditional block, a note |
| examples/payment.seq | self messages, a nested loop inside a condition |
| examples/pipeline.seq | short labels and a two-branch hand-off |
moon check --target wasm-gc --deny-warn
moon test --target wasm-gcpub(all) enum Item {
Message(Message)
SelfMessage(SelfMessage)
Note(Note)
GroupStart(GroupStart)
GroupElse(String)
GroupEnd
}pub(all) struct Message {
from : String
to : String
label : String
style : ArrowStyle
open_head : Bool
}pub(all) struct ParseError {
line : Int
message : String
}fn char_width(c : Char) -> Intfn clip_to_width(text : String, limit : Int) -> (String, Int)fn pad_center(text : String, target : Int) -> Stringfn pad_right(text : String, target : Int) -> StringInstall
Download zipRender sequence diagrams as terminal text: a small DSL, a layout engine, and a CLI.