Skip to content

Command-line tool

larrygram-cli · 1.0.0-alpha.1 (unreleased)

larrygram-cli reads Visio drawings and prints a summary, renders a page, or exports every page as PNG or SVG. It runs through the same command registry as the app (file.inspect, file.render, file.export), so a script sees the same behavior as a person.

Only inspect output and --help go to standard output. Errors and warnings go to standard error, one line each.

larrygram-cli - inspect, render and export Visio drawings
Usage:
larrygram-cli inspect <file> [--json] [--page N]
larrygram-cli render <file> --out <path> [--page N] [--format png|svg]
[--scale PPI] [--background #RRGGBB|none] [--strict]
larrygram-cli export <file> --out <dir> [--format png|svg] [--scale PPI]
[--strict]
larrygram-cli --help

Build it from the repository with:

Terminal window
cargo build --release -p larrygram-cli
./target/release/larrygram-cli --help

Summarises a document: its kind, pages, masters, styles and themes.

Flag Meaning Default
--json Print the summary as one JSON object text
--page N Summarise one page, counted from 1 every page
Terminal window
larrygram-cli inspect flowchart.vsdx
kind: drawing
pages: 2
1: Page-1 8.5 x 11 in, 3 shapes, 0 warnings
2: (unnamed) 11 x 8.5 in, 0 shapes, 2 warnings
masters: 1
styles: 4
themes: 1
warnings: 2

With --json, the keys are stable:

{
"kind": "drawing",
"masters": 1,
"pages": [
{ "height": 11.0, "index": 1, "name": "Page-1", "shapes": 3, "warnings": 0, "width": 8.5 },
{ "height": 8.5, "index": 2, "name": "", "shapes": 0, "warnings": 2, "width": 11.0 }
],
"styles": 4,
"themes": 1,
"warnings": 2
}

kind is drawing, stencil or template. Page sizes are in inches. A size that cannot be computed is 0.

Renders one page to a PNG or SVG file.

Flag Meaning Default
--out PATH The output file (required) —
--page N The page to render, counted from 1 the first page
--format png|svg The output format from the --out extension
--scale PPI Device scale in pixels per inch; a positive number 96
--background C #RRGGBB for an opaque color, or none for transparent the page’s own background
--strict Exit with code 4 when warnings occurred (the file is still written) off
Terminal window
larrygram-cli render flowchart.vsdx --out page-1.png --scale 192
larrygram-cli render flowchart.vsdx --out page-2.svg --page 2 --background none

Renders every page of a document into a directory. Files are named page-1.png, page-2.png and so on.

Flag Meaning Default
--out DIR The output directory (required) —
--format png|svg The output format png
--scale PPI Device scale in pixels per inch 96
--strict Exit with code 4 when warnings occurred off
Terminal window
larrygram-cli export flowchart.vsdx --out pages/ --format svg
Code Meaning
0 Success
1 Usage error (bad arguments)
2 Input error: the file is missing, unreadable or cannot be parsed
3 Render or output error
4 Warnings occurred and --strict is set

Fail a job when a drawing renders with warnings:

Terminal window
for f in diagrams/*.vsdx; do
larrygram-cli export "$f" --out "build/${f%.vsdx}" --format svg --strict || exit 1
done
Inspect a drawing and render a page from the terminal.