Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit e8819a2

Browse files
committed
feat: Add trait rendering mode option to GenerateCommand
1 parent 27d5378 commit e8819a2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Console/Command/GenerateCommand.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Tasuku43\MermaidClassDiagram\ClassDiagramRenderer\ClassDiagramBuilder;
1515
use Tasuku43\MermaidClassDiagram\ClassDiagramRenderer\Node\NodeParser;
1616
use Tasuku43\MermaidClassDiagram\ClassDiagramRenderer\RenderOptions\RenderOptions;
17+
use Tasuku43\MermaidClassDiagram\ClassDiagramRenderer\TraitRenderMode;
1718

1819
class GenerateCommand extends Command
1920
{
@@ -32,6 +33,12 @@ protected function configure()
3233
InputOption::VALUE_REQUIRED,
3334
'Comma-separated relationship types to exclude: dependency,composition,inheritance,realization'
3435
);
36+
$this->addOption(
37+
'trait-mode',
38+
null,
39+
InputOption::VALUE_REQUIRED,
40+
'Trait rendering mode: with-traits | flatten (default: flatten)'
41+
);
3542
}
3643

3744
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -56,6 +63,24 @@ private function buildRenderOptions(InputInterface $input): RenderOptions
5663
{
5764
$options = RenderOptions::default();
5865

66+
// Trait render mode
67+
$traitMode = (string)($input->getOption('trait-mode') ?? '');
68+
switch (strtolower($traitMode)) {
69+
case 'with-traits':
70+
case 'with_traits':
71+
case 'with':
72+
$options->traitRenderMode = TraitRenderMode::WithTraits;
73+
break;
74+
case 'flatten':
75+
case 'flat':
76+
case '':
77+
// default (Flatten)
78+
break;
79+
default:
80+
// ignore unknown; keep default
81+
break;
82+
}
83+
5984
$exclude = (string)($input->getOption('exclude-relationships') ?? '');
6085
if ($exclude === '') {
6186
return $options;

0 commit comments

Comments
 (0)