Last updated
Last updated
StarUML can be used as CLI (Command Line Interface) in terminal. With the CLI feature, you can generate various artifacts including source codes, documents (markdown, HTML, etc.), diagram images without launching StarUML GUI. Therefore, you can use CLI in your build script to automate artifacts generation based on your software model.
It is useful to make an alias for StarUML application in terminal as below:
You can create an alias for StarUML application in PowerShell as below:
In Linux, you don't need to create alias. If you installed StarUML successfully, you can run with staruml
in Terminal without additional configuration.
You can use four commands in CLI mode. If you omit the supported commands, StarUML will be launched as GUI mode.
You can see what kind of commands are supported by typing with help (--help
) option.
You can generate textual artifacts with the below CLI command:
<file>
: A model file (.mdj) to load
option -t
, --template
: A template file (.ejs) to apply
option -o
, --output
: output file name (default: output.txt
)
option -s
, --select
: query to select elements (default: @Project
)
Here is an example to generate a HTML file.
You can generate multiple files with the select option as below:
Note that you can also use EJS template syntax in the output option. Sometimes the element name cannot be used as a filename (including special characters like /
, !
, #
, ?
, etc.). You can use filename()
function to convert a string to a legal filename string in output option like -o "out/<%=filenamify(element.name)%>.java"
.
In EJS template string (in .ejs files or in output option), you can use below variables:
element
: The element retrieved by the select option.
The image
command allows you can generate image files for diagrams:
<file>
: A model file (.mdj) to load
option -f
, --format
: image file format. One of png
, jpeg
, or svg
. (default: png
)
option -o
, --output
: output file name.
option -s
, --select
: query to select diagrams (default: @Diagram
)
Here is an example to export all diagrams as PNG images in out
folder:
The html
command allows you can generate HTML docs for the model file:
<file>
: A model file (.mdj) to load
option -o
, --output
: output path. (default: ./html-docs
)
Here is an example to generate HTML docs:
The pdf command allows you can generate PDF document for diagrams:
<file>
: A model file (.mdj) to load
option -o
, --output
: output file name. (default: output.pdf
)
option -s
, --select
: query to select diagrams (default: @Diagram
)
option -z
, --size
: page size. One of 4A0, 2A0, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, RA0, RA1, RA2, RA3, RA4, SRA0, SRA1, SRA2, SRA3, SRA4, Executive, Folio, Legal, Letter, Tabloid (default: A4
).
option -l
, --layout
: page layout. landscape
or portrait
. (default: landscape
)
option -n
, --showname
: Show diagram name on page top. yes
or no
. (default: yes
)
Here is an example to generate PDF document (A3-sized portrait) including all diagrams:
The exec command allows you can execute a command:
<file>
: A model file (.mdj) to load before executing a command
option -c
, --command
: command id. (e.g. application:main-log
)
option -a
, --arg
: argument for the command
Here is an example to execute a command:
The ejs
command allow to generate textual artifacts from a user's software model file (.mdj). You can write your own templates with . You can find simple examples for EJS at .
This command selects all classes (UMLClass type) in myproject.mdj
and then apply the java-class.ejs
template for each class and save it as a .java
file with the name of the class. You can get more information about the query expression to select elements at the section.
app
: The application object. (See )
filenamify
: A function convert a string to a legal filename string. (See )