scrap

Statecharts Rhapsody

Features: - output as: - [x] [xstate configuration in json][xstate-format] - [x] [state-machine-cat in json][smcat] - [x] REPL - Shell friendly - [x] Colored output - [x] Pipe-able (e.g: cat f.scdl | scrap eval or scrap code f.scdl | cat) which disable the colored output. Useful when piping to file or running on CI.

Hooked CLI

Scrap will automatically use this CLI below if it's available on the system host. In Games term, think of it as an extension pack where some features will be enabled if you install it 😉

smcat

Install console npm -g state-machine-cat 👆 How to install npm!

Unlocked features: - smcat become the default output when --format smcat is specified - flag --as can accept 🗹 when --format smcat is specified - [x] svg -> Scalable Vector Graphics - [x] dot -> Alias for Graphviz format/language - [x] smcat -> state-machine-cat language (default) - [x] json -> AST representation of state-machine-cat in JSON (ex-default) - [ ] ast -> AST representation of state-machine-cat - [ ] html -> HTML - [x] scxml -> State Chart XML (W3C standard) - [ ] scjson -> experimental JSON representation of state-machine-cat - [x] xmi -> XML Metadata Interchange (OMG standard)

graph-easy

⚠️ smcat need to be installed first

Install console cpanm graph-easy 👆 How to install cpanminus!

Unlocked features: - flag --as can accept 🗹 when --format graph is specified - [x] ascii -> ASCII art rendering - [x] boxart -> Unicode Boxart rendering (default) - [ ] html -> HTML - [x] svg -> Scalable Vector Graphics - [x] dot -> the DOT language - [x] txt -> Graph::Easy text - [ ] vcg -> VCG (Visualizing Compiler Graphs - a subset of GDL) text - [ ] gdl -> GDL (Graph Description Language) text - [ ] graphml -> GraphML - [x] bmp -> Windows bitmap - [x] gif -> GIF - [ ] hpgl -> HP-GL/2 vector graphic - [x] jpg -> JPEG - [ ] pcl -> PCL printer language - [x] pdf -> PDF - [x] png -> PNG - [x] ps -> Postscript - [x] ps2 -> Postscript with PDF notations (see graphviz documentation) - [ ] tga -> Targa bitmap - [x] tif -> TIFF bitmap

dot

⚠️ smcat need to be installed first

Unlocked features: - flag --as can accept 🗹 when --format graph is specified - [x] bmp -> Windows Bitmap Format (blob) - [x] canon/dot/gv/xdot -> DOT/Graphviz language - [ ] cgimage -> CGImage bitmap format - [x] eps -> Encapsulated PostScript - [ ] exr -> OpenEXR - [x] fig -> FIG graphics language - [x] gd/gd2 -> GD/GD2 formats (blob) - [x] gif -> Graphics Interchange Format (blob) - [ ] gtk -> GTK canvas - [ ] ico -> Icon Image File Format - [ ] imap/cmapx -> Server-side and client-side imagemaps - [ ] imapnp/cmapxnp -> These are identical to the imap and cmapx formats, except they rely solely on rectangles as active areas - [ ] jp2 -> JPEG 2000 - [x] jpg/jpeg/jpe -> JPEG (blob) - [x] json/json0/dotjson/xdotjson -> Dot graph represented in JSON format - [ ] pct/pict -> PICT - [ ] pdf -> Portable Document Format (PDF). This option does not support anchors, etc. Refer to ps2 instead - [x] pic -> Kernighan's PIC graphics language - [x] plain/plain-ext -> Simplified version of dot language. - [x] png -> Portable Network Graphics format (blob) - [x] ps -> PostScript - [x] ps2 -> PostScript for PDF - [ ] psd -> Photoshop Document - [ ] sgi -> Silicon Graphics Image - [x] svg/svgz -> Scalable Vector Graphics (blob:svgz) - [ ] tga -> Truevision TGA - [x] tif/tiff -> TIFF (Tag Image File Format) (blob) - [x] tk -> TK graphics language - [x] vml/vmlz -> Vector Markup Language (VML) (blob:vmlz) - [x] vrml -> Virtual Reality Modeling Language - [x] wbmp -> Wireless BitMap format (blob) - [ ] webp -> Image format for the Web (blob) - [ ] xlib/x11 -> Xlib canvas

Usage

```console $ scrap help

Statecharts Rhapsody

USAGE: scrap

FLAGS: -h, --help Prints help information -V, --version Prints version information

SUBCOMMANDS: code Generate from scdlang file declaration to another format [aliases: generate, gen, declaration, declr] eval Evaluate scdlang expression in interactive manner [aliases: repl] help Prints this message or the help of the given subcommand(s) ```

scrap help code

```console $ scrap code --help

Generate from scdlang file declaration to another format

USAGE: scrap code [FLAGS] [OPTIONS] --format [DIST]

FLAGS: -h, --help Prints help information --stream Parse the file line by line

OPTIONS: --as Select parser output [possible values: json, svg, dot, smcat, html, scxml, xmi, ascii, boxart, bmp, gif, jpg, pdf, png, ps, ps2, tif] -f, --format Select output format [possible values: xstate, smcat, graph]

ARGS: File to print / concatenate Output the result to this directory / file ```

scrap help repl

```console $ scrap repl --help

Evaluate scdlang expression in interactive manner

USAGE: scrap eval [FLAGS] [OPTIONS] --format

FLAGS: -h, --help Prints help information -i, --interactive Prints result on each expression --strict Exit immediately if an error occurred

OPTIONS: --as Select parser output [possible values: json, svg, dot, smcat, html, scxml, xmi, ascii, boxart, bmp, gif, jpg, pdf, png, ps, ps2, tif] -f, --format Select output format [possible values: xstate, smcat, graph] ```

Tips & Tricks

Some CLI and tools that can came handy: - watchexec -> Executes commands in response to file modifications. - live-server -> A simple development http server with live reload capability. Useful to quickly preview the svg output - bat -> A cat(1) clone that supports syntax highlighting. Useful for trying various syntax highlighter when displaying the output.

Live preview the visual representation in terminal window

shell watchexec "scrap code $FILE.scl -f graph" --clear --watch $FILE.scl live preview boxart.gif

Live preview the visual representation of media output (svg, jpg, png, etc)

Inspect each line

shell cat $FILE.scl | scrap repl --interactive --format graph Inspect each line

Only inspect result

shell cat $FILE.scl | scrap repl --interactive --format xstate 2>/dev/null Only inspect result on each line

Only inspect error

shell cat $FILE.scl | scrap repl --interactive --format xstate 1>/dev/null Only inspect error on each line

Log error to file

shell scrap code $FILE.scl --stream 2> $OUTPUT.log Log error to file

Print in plain format (no syntax highlighter)

shell scrap code $FILE.scl --format xstate --stream 2>&1 | cat Print in plain format

Only print result

shell scrap code $FILE.scl --format xstate --stream 2>/dev/null | cat Only print result and in plain format

Only print error

shell scrap code $FILE.scl --format xstate --stream 2>&1 1>/dev/null | cat Only print error and in plain format

Inspect and log each line to file
Inspect and log error

shell cat $FILE.scl | scrap repl --interactive --format xstate 2> $OUTPUT.log Inspect and log error

Inspect and log result

shell cat $FILE.scl | scrap repl --interactive --format xstate > $OUTPUT.log Inspect and log result