-
-
Notifications
You must be signed in to change notification settings - Fork 15
Command Line Interface (CLI)
At the moment it is recommended to created a C# Console Application per Application Architecture project e.g. dotnet.eShop.Architecture.Cli was created specifically for E-Shop sample .NET application .
The Console Application should reference C4InterFlow.Automation
package.
The Program.cs
file should contain the following code to take advantage of all CLI Commands already implemented in C4InterFlow.Cli namespace.
using C4InterFlow.Cli.Root;
using C4InterFlow.Cli.Commands;
var root = RootCommandBuilder
.CreateDefaultBuilder(args)
.Configure(context =>
{
context.Add<DrawDiagramsCommand>();
context.Add<QueryUseFlowsCommand>();
context.Add<QueryByInputCommand>();
context.Add<ExecuteAaCStrategyCommand>();
});
await root.Run();
All custom AaC Read/Write Strategies can also be implemented in this Console Application e.g. CSharpToCSharpBasketApiAaCGenerator, CSharpToYamlBasketApiAaCGenerator etc.
All command support -?
, -h
, --help
option that shows help and usage information.
Use execute-aac-strategy
command to generate AaC in either C# or YAML. AaC can be generated either from C# source code or from CSV Architecture Catalogue making the following four scenarios possible:
- Generating C# AaC from C# source code
- Generating C# AaC from CSV Architecture Catalogue
- Generating YAML AaC from C# source code
- Generating YAML AaC from CSV Architecture Catalogue
NOTE: More scenarios may be supported out-of-the-box in the future. C4InterFlow is using Strategy pattern and Generic interfaces, which allow for custom implementations of any unsupported scenarios.
dotnet.eShop.Architecture.Cli execute-aac-strategy [options]
-aac-rn
, --aac-root-namespace
: Architecture As Code root Namespace. (Required).
-aac-outp
, --aac-output-path
: The path to the Architecture As Code output (Required).
-aac-ws
, --aac-writer-strategy
: The full Type name of the Architecture As Code Writer Strategy to execute (Required).
-ps
, --params
: The key/value pairs of additional command parameters.
NOTE: AaC Strategy parameters are spesific for each Strategy e.g. any AaC generators that ultimately extend C4InterFlow.Automation.CSharpToAnyAaCStrategy
would require software-system-source-path
and software-system-name
parameters.
dotnet.eShop.Architecture.Cli execute-aac-strategy --aac-root-namespace dotnet.eShop.Architecture --aac-output-path dotnet.eShop.Architecture\dotnet.eShop.Architecture.csproj --aac-writer-strategy "dotnet.eShop.Architecture.Cli.CSharpToCSharpBasketApiAaCGenerator, dotnet.eShop.Architecture.Cli" --params software-system-source-path="C:\Repos\eShop-main\src\Basket.API\Basket.API.csproj" --params software-system-name="BasketApi"
dotnet.eShop.Architecture.Cli execute-aac-strategy --aac-root-namespace dotnet.eShop.Architecture --aac-output-path dotnet.eShop.Architecture\dotnet.eShop.Architecture\Yaml --aac-writer-strategy "dotnet.eShop.Architecture.Cli.CSharpToYamlCatalogApiAaCGenerator, dotnet.eShop.Architecture.Cli" --params software-system-source-path="C:\Repos\eShop-main\src\Catalog.API\Catalog.API.csproj" --params software-system-name="CatalogApi"
Use draw-diagrams
command to draw diagrams of different Types, Scopes and Level of Details using AaC in either C# or YAML.
dotnet.eShop.Architecture.Cli draw-diagrams [options]
-aac-inp
, --aac-input-paths
: The path to the Architecture As Code input (Required).
-aac-rs
, --aac-reader-strategy
: The full Type name of the Architecture As Code Reader Strategy to use (Required).
-i
, --interfaces
: The aliases of the interfaces to be used as input for a Command. Multiple values are allowed.
-iif
, --interfaces-input-file
The file where the aliases of the Interfaces, which are intended to be used as input for a Command, can be loaded from.
-bp
, --business-processes
: The aliases of Business Process for which to draw the Diagram(s). Multiple values are allowed.
-s
, --scopes
: Scopes of Diagram(s) to draw. Multiple values are allowed. Default: *
(all Scopes).
Possible values:
business-process
component
component-interface
container
container-interface
software-system
software-system-interface
software-systems
-t
, --types
: Types of Diagram(s) to draw. Multiple values are allowed. Default: *
(all Types).
Possible values:
c4
c4-static
sequence
-l
, --levels-of-details
: Levels of Details of the Diagram(s). Multiple values are allowed. Default: *
(all Levels of Details).
Possible values:
component
container
context
-siinout
, --show-interface-input-output
: Show Interface Input and Output. Default: False
.
NOTE: This option is used for component
Level of Details only.
-od
, --output-dir
: The output directory for the current command. Default: Current working directory.
-osd
, --output-sub-dir
| The sub-directory where the Diagram(s) should be saved.
-np
, --name-prefix
: The name prefix for a Diagram.
-f
, --formats
: Diagram format(s) to draw. Multiple values are allowed.
NOTE: Diagram(s) in puml
format are always generated by default .
Possible values:
png
svg
md
dotnet.eShop.Architecture.Cli draw-diagrams --aac-input-paths dotnet.eShop.Architecture.dll --aac-reader-strategy "C4InterFlow.Automation.Readers.CSharpAaCReaderStrategy,C4InterFlow.Automation" --interfaces dotnet.eShop.Architecture.SoftwareSystems.*.Containers.*.Components.*.Interfaces.*
This command will generate diagrams of all Types, all Scopes and all Levels of Details for all Interfaces of all Components of all Containers of all Software Systems in dotnet.eShop.Architecture
Namespace. It will use C# AaC (aac-reader-strategy
) that is compiled as dotnet.eShop.Architecture.dll (aac-input-paths
)
dotnet.eShop.Architecture.Cli draw-diagrams --aac-input-paths "dotnet.eShop.Architecture\Yaml" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.*.Components.*.Interfaces.* dotnet.eShop.Architecture.SoftwareSystems.CatalogApi.Containers.*.Components.*.Interfaces.* --types sequence --formats svg
This command will generate Plant UML - Sequence diagrams of Component interface Scope and all Levels of Details for all Interfaces of all Components of all Containers of BasketApi and CatalogApi Software Systems in dotnet.eShop.Architecture
Namespace. It will use YAML AaC (aac-reader-strategy
) that is saved in .yaml
files located in dotnet.eShop.Architecture\Yaml directory (aac-input-paths
)
Use query-use-flows
command to finds all interface(s) that Use given interface(s) in their Flows.
dotnet.eShop.Architecture.Cli query-use-flows [options]
-i
, --interfaces
: The aliases of the interfaces to be used as input for a Command. Multiple values are allowed.
-r
, --recursive
: Indicates if the Query should be executed recursively. Default: False
.
- Non-recursive Query will return only the immediate (first) instance of a given Interface being Used in a Flow by another Interface.
- Recursive Query will follow the whole Use Flow tree upwards, and will return only the top-most Interface from it.
-qof
, --query-output-file
: The name of the file where the Query results should be saved.
NOTE: If a value for this option is not provided, CLI will output Query results to Console.
-a
, --append
: Append Query results to an output file. Default: False
.
-aac-inp
, --aac-input-paths
: The path to the Architecture As Code input (Required).
-aac-rs
, --aac-reader-strategy
: The full Type name of the Architecture As Code Reader Strategy to use (Required).
-incls
, --include-self
: Is Interface queried by included in the query result. Default: False
.
Give the Interface dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Grpc.Components.BasketService.Interfaces.UpdateBasket
with the following AaC definition
dotnet:
eShop:
Architecture:
SoftwareSystems:
BasketApi:
Containers:
Grpc:
Components:
BasketService:
Interfaces:
UpdateBasket:
Label: Update Basket
IsPrivate: false
Flow:
Flows:
- Type: If
Expression: string.IsNullOrEmpty(userId)
Flows:
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Grpc.Components.BasketService.Interfaces.ThrowNotAuthenticated
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Grpc.Components.BasketService.Interfaces.MapToCustomerBasket
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.UpdateBasketAsync
- Type: If
Expression: response is null
Flows:
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Grpc.Components.BasketService.Interfaces.ThrowBasketDoesNotExist
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Grpc.Components.BasketService.Interfaces.MapToCustomerBasketResponse
And the Interface dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.UpdateBasketAsync
with the following AaC definition
dotnet:
eShop:
Architecture:
SoftwareSystems:
BasketApi:
Containers:
Data:
Components:
RedisBasketRepository:
Interfaces:
UpdateBasketAsync:
Label: Update Basket Async
IsPrivate: false
Flow:
Flows:
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisDatabase.Interfaces.StringSetAsync
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.GetBasketKey
- Type: Use
Expression: dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.GetBasketAsync
When the following command is executed
dotnet.eShop.Architecture.Cli query-use-flows --aac-input-paths "dotnet.eShop.Architecture\Yaml" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisDatabase.Interfaces.StringSetAsync
Then the following result will be returned
dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.UpdateBasketAsync
When the following command is executed
dotnet.eShop.Architecture.Cli query-use-flows --aac-input-paths "dotnet.eShop.Architecture\Yaml" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisDatabase.Interfaces.StringSetAsync --include-self
Then the following result will be returned
dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisDatabase.Interfaces.StringSetAsync
dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.UpdateBasketAsync
When the following command is executed
dotnet.eShop.Architecture.Cli query-use-flows --aac-input-paths "dotnet.eShop.Architecture\Yaml" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisDatabase.Interfaces.StringSetAsync --include-self --recursive
Then the following result will be returned
dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Grpc.Components.BasketService.Interfaces.UpdateBasket
dotnet.eShop.Architecture.SoftwareSystems.BasketApi.Containers.Data.Components.RedisBasketRepository.Interfaces.UpdateBasketAsync