In this tutorial you will:
This tutorial works on MacOS and Linux, but should be adaptable to Windows easily.
Only the cue
utility is required. You can download is from this page
mkdir $TMPDIR/helloworld
cd $TMPDIR/helloworld
Init a new cue module:
cue mod init
The vendor the cue4puml4c4 library:
mkdir -p cue.mod/pkg/github.com/owulveryck/cue4puml4c4
git clone https://github.com/owulveryck/cue4puml4c4.git cue.mod/pkg/github.com/owulveryck/cue4puml4c4
Write the content below in a file name command_tool.cue
with your favorite editor:
package main
import (
"tool/cli"
"text/template"
"github.com/owulveryck/cue4puml4c4:c4"
)
command: genpuml: {
c1: cli.Print & {
text: template.Execute(c4.plantumlTemplate, C1) // change C1 here with the name of your object
}
}
in a file named test.cue
write the content below:
package main
import "github.com/owulveryck/cue4puml4c4:c4"
C1: c4.#C1 & { // the name C1 should be coherent with the name you declare in the command
Systems: [{id: "sample", label: "my sample"}]
}
run the following command to generate the plantuml diagram:
cue genpuml | grep -v '^$'
Note: the | grep
command is to remove the blank lines for brevity but does not impact the result.
Generates the following output:
@startuml MyDiagram
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/GCPCommon.puml
LAYOUT_TOP_DOWN()
HIDE_STEREOTYPE()
/'Relation Tags'/
/'Element Tags'/
/' Systems '/
System(sample,"my sample")
SHOW_LEGEND()
@enduml
Which renders as:
@startuml MyDiagram
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/GCPCommon.puml
LAYOUT_TOP_DOWN()
HIDE_STEREOTYPE()
/'Relation Tags'/
/'Element Tags'/
/' Systems '/
System(sample,"my sample")
SHOW_LEGEND()
@enduml
You can copy/paste the content in plantuml server online to see how it renders
rm $TMPDIR/helloworld/*.cue
rmdir $TMPDIR/helloworld