Quick Start

Check Environment

We can perform a environment check using the following command:

1plantumlcli -c

In plantumlcli, the available environments can be categorized into local environments and remote environments, as follows:

  • Local Environments: Environments based on Java (both Oracle JDK and OpenJDK are supported) and the local plantuml.jar package. UML diagram generation is achieved by invoking the java -jar plantuml.jar command.

  • Remote Environments: Environments based on the plantuml-server and the official PlantUML website. UML images are obtained by accessing their APIs, and the images are generated remotely and loaded into the local environment.

In the current environment, we are only connected to a docker-based plantuml-server. The inspection results are as follows:

1Local plantuml not detected or has problem.
2Error : ValueError('Plantuml jar file not given.')
3Remote plantuml detected.
4PlantUML Server Version 1202306
5Remote host : http://localhost:18080
6Connection time : 0.017s

Export Diagrams From Code

Here is one example plantuml code in file common.puml.

 1@startuml
 2hide empty description
 3
 4state "Idle" as idle
 5state "Ringing" as ringing
 6state "Dialing" as dialing
 7state "Calling" as calling
 8
 9[*] -> idle : power on
10idle -> [*] : power off
11
12idle -> ringing : incoming call
13ringing -> calling : pick up
14
15idle -> dialing : outgoing call
16dialing -> calling : be answered
17dialing -> idle : nobody
18
19calling -down-> idle : hang up
20@enduml

Export to ASCII Arts

Some very simple UML diagrams can be viewed directly in the command line using ASCII art. For example, the following code for helloworld.puml:

1@startuml
2Bob -> Alice : hello
3@enduml

Enter the following command:

1plantumlcli -T helloworld.puml

You will see:

1helloworld.puml: 
2     ┌───┐          ┌─────┐
3     │Bob│          │Alice│
4     └─┬─┘          └──┬──┘
5       │    hello      │   
6       │──────────────>│   
7     ┌─┴─┐          ┌──┴──┐
8     │Bob│          │Alice│
9     └───┘          └─────┘

Export to PNG Image

Convert the code to PNG image with the following command

1plantumlcli -t png -o common.dat.png common.puml

And this is the common.dat.png:

../../_images/common.dat.png

Export to SVG Image

Convert the code to SVG image with the following command

1plantumlcli -t svg -o common.dat.svg common.puml

And this is the common.dat.svg:

../../_images/common.dat.svg

Export to EPS Image

Convert the code to EPS image with the following command

1plantumlcli -t eps -o common.dat.eps common.puml

And this is the common.dat.eps.

Warning

The EPS format has been deprecated and is no longer widely supported in many applications, so it is not recommended to continue using it. If you need to use vector graphics in LaTeX, it is recommended to use the PDF format. If you need to import vector graphics into Microsoft Office software, it is recommended to use the SVG format.

Export to PDF Image

Convert the code to PDF image with the following command

1plantumlcli -t pdf -o common.dat.pdf common.puml

And this is the common.dat.pdf.

Note

If you need to convert it to PDF format, you will need to install plantumlcli[pdf] like this:

pip install plantumlcli[pdf]

More Details

You can see the help information with

1plantumlcli --help

And this is the help information for plantumlcli

 1Usage: plantumlcli [OPTIONS] [SOURCES]...
 2
 3Options:
 4  -v, --version                   Show package's version information.
 5  -j, --java TEXT                 Path of java executable file (will load from
 6                                  environment when not given).  [default:
 7                                  (java from ${PATH})]
 8  -p, --plantuml TEXT             Path of plantuml jar file (will load from
 9                                  ${PLANTUML_JAR} when not given).
10  -r, --remote-host TEXT          Remote host of the online plantuml editor
11                                  (will load from ${PLANTUML_HOST} when not
12                                  given).  [default:
13                                  http://www.plantuml.com/plantuml]
14  -L, --use-local                 Use local plantuml only.
15  -R, --use-remote                Use remote plantuml only.
16  -c, --check                     Check usable plantuml.
17  -u, --url                       Print url of remote plantuml resource
18                                  (ignore -L and -R).
19  --homepage-url                  Print url of remote plantuml editor (ignore
20                                  -L, -R and -u).
21  -t, --type [TXT|PNG|SVG|EPS|PDF]
22                                  Type of plantuml resource. (Attention that
23                                  the PDF format is only natively supported by
24                                  few versions of plantuml-server. Please
25                                  install 'plantumlcli[pdf]' and Cairo
26                                  environment to make sure the export to PDF
27                                  can be processed.)  [default: PNG]
28  -T, --text                      Display text uml graph by stdout (ignore
29                                  -t).
30  -o, --output TEXT               Paths of output files (relative path
31                                  supported, based on output dir in -O).
32  -O, --output-dir DIRECTORY      Base path for outputting files.  [default:
33                                  (current path)]
34  -n, --concurrency INTEGER       Concurrency when running plantuml.
35                                  [default: 4]
36  -h, --help                      Show this message and exit.