Lakitna/cli-diagram

Define full diagrams with a single string

Lakitna opened this issue · 0 comments

Because I can, because it's good practice, and because it allows cli-diagram to be a command-line tool.

Allow the Diagram constructor to parse a diagram-definition string. The parsing must be extendable.

Ideally, all features are included. Though the options objects are probably not feasible to fully implement here. Setting options on Diagram should still be possible.

Examples:

> new Diagram('[ left box ]-->[ middle box ]---[ right box ]').draw();
┌──────────────┐    ┌────────────────┐    ┌───────────────┐
│              │    │                │    │               │
│   left box   │───▶│   middle box   │────│   right box   │
│              │    │                │    │               │
└──────────────┘    └────────────────┘    └───────────────┘
λ diagram "[ left box ](-->,<--:label)[ middle box ]"
┌──────────────┐           ┌────────────────┐    ┌───────────────┐
│              │──────────▶│                │    │               │
│   left box   │           │   middle box   │────│   right box   │
│              │◀─┤label├──│                │    │               │
└──────────────┘           └────────────────┘    └───────────────┘