structurizr / cli

A command line utility for Structurizr.
https://docs.structurizr.com/cli
Apache License 2.0
500 stars 77 forks source link

Add 'output' option to the Export command #5

Closed safor closed 4 years ago

safor commented 4 years ago

Before the proposed change the export command creates files in the same directory as the workspace. The proposed changes add a new functionality to the export command - the output option allows to specify a relative or absolute path to the directory, where files should be created.

Example 1 - run export command without options - outputs help with the new option.

C:\github\safor\structurizr-cli\build\libs> java -jar structurizr-cli-1.4.4.jar export
Structurizr CLI v1.4.4
Missing required options: w, f
usage: export
 -f,--format <arg>      Export format:
                        plantuml|websequencediagrams|mermaid|ilograph|json
 -o,--output <arg>      Path to an output directory
 -w,--workspace <arg>   Path or URL to the workspace JSON file/DSL file(s)

Example 2 - run export command without output option - creates files in the same directory as the workspace.

C:\github\safor\structurizr-cli\build\libs> java -jar structurizr-cli-1.4.4.jar export -workspace demo.dsl -format plantuml
Structurizr CLI v1.4.4
Exporting workspace from demo.dsl
 - loading workspace from DSL
 - writing C:\github\safor\structurizr-cli\build\libs\structurizr-SystemContext.puml
 - finished

Example 3 - run export command with empty output option - displays help.

C:\github\safor\structurizr-cli\build\libs> java -jar structurizr-cli-1.4.4.jar export -workspace demo.dsl -format plantuml -output
Structurizr CLI v1.4.4
Missing argument for option: o
usage: export
 -f,--format <arg>      Export format:
                        plantuml|websequencediagrams|mermaid|ilograph|json
 -o,--output <arg>      Path to an output directory
 -w,--workspace <arg>   Path or URL to the workspace JSON file/DSL file(s)

Example 4 - run export command with relative output folder - output folder is created in the same directory as the workspace.

C:\github\safor\structurizr-cli\build\libs>java -jar structurizr-cli-1.4.4.jar export -workspace demo.dsl -format plantuml -output diagrams
Structurizr CLI v1.4.4
Exporting workspace from demo.dsl
 - loading workspace from DSL
 - writing C:\github\safor\structurizr-cli\build\libs\diagrams\structurizr-SystemContext.puml
 - finished

Example 5 - run export command with relative hierarchical output folder - hierarchy of output folders is created in the same directory as the workspace.

C:\github\safor\structurizr-cli\build\libs>java -jar structurizr-cli-1.4.4.jar export -workspace demo.dsl -format plantuml -output output\diagrams
Structurizr CLI v1.4.4
Exporting workspace from demo.dsl
 - loading workspace from DSL
 - writing C:\github\safor\structurizr-cli\build\libs\output\diagrams\structurizr-SystemContext.puml
 - finished

Example 6 - run export command from different location - output folder is created in the same directory, where application was executed.

C:\github\safor\structurizr-cli>java -jar build\libs\structurizr-cli-1.4.4.jar export -workspace build\libs\demo.dsl -format plantuml -output diagrams
Structurizr CLI v1.4.4
Exporting workspace from build\libs\demo.dsl
 - loading workspace from DSL
 - writing C:\github\safor\structurizr-cli\diagrams\structurizr-SystemContext.puml
 - finished

Example 7 - run export command with output directry specified as absolute path - output directory is created at the specified path.

C:\github\safor\structurizr-cli\build\libs>java -jar structurizr-cli-1.4.4.jar export -workspace demo.dsl -format plantuml -output c:\temp\diagrams
Structurizr CLI v1.4.4
Exporting workspace from demo.dsl
 - loading workspace from DSL
 - writing C:\temp\diagrams\structurizr-SystemContext.puml
 - finished
simonbrowndotje commented 4 years ago

Thanks again!