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.
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 😉
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)
⚠️ 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
⚠️ 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
```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]
FLAGS: -h, --help Prints help information --stream Parse the file line by line
OPTIONS:
--as
ARGS:
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
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 the visual representation of media output (svg, jpg, png, etc)
For SVG
shell
watchexec "scrap code $INPUT.scl -o $OUTPUT.svg -f smcat --as svg" --clear --watch $INPUT.scl
live-server --watch=$INPUT.scl --entry-file=$OUTPUT.svg --port=2019 --wait=2020
google-chrome --app=http://localhost:2019
For VSCode user, you can --output
it --as
media file like png or jpg then open it in VSCode
shell
watchexec "scrap code $INPUT.scl -o $OUTPUT.png -f graph --as png" --watch $INPUT.scl
code $OUTPUT.png
Inspect each line
shell
cat $FILE.scl | scrap repl --interactive --format graph
Only inspect result
shell
cat $FILE.scl | scrap repl --interactive --format xstate 2>/dev/null
Only inspect error
shell
cat $FILE.scl | scrap repl --interactive --format xstate 1>/dev/null
Log error to file
shell
scrap code $FILE.scl --stream 2> $OUTPUT.log
Print in plain format (no syntax highlighter)
shell
scrap code $FILE.scl --format xstate --stream 2>&1 | cat
Only print result
shell
scrap code $FILE.scl --format xstate --stream 2>/dev/null | cat
Only print error
shell
scrap code $FILE.scl --format xstate --stream 2>&1 1>/dev/null | cat
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 result
shell
cat $FILE.scl | scrap repl --interactive --format xstate > $OUTPUT.log