Skip to content

Commit be294f7

Browse files
committed
Generate default filename from format string
1 parent ee2d74e commit be294f7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/GenerateDiagramCommand.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ class GenerateDiagramCommand extends Command
1212
{
1313
const FORMAT_TEXT = 'text';
1414

15+
const DEFAULT_FILENAME = 'graph';
16+
1517
/**
1618
* The console command name.
1719
*
1820
* @var string
1921
*/
20-
protected $signature = 'generate:erd {filename=graph.png} {--format=png}';
22+
protected $signature = 'generate:erd {filename?} {--format=png}';
2123

2224
/**
2325
* The console command description.
@@ -72,10 +74,16 @@ public function handle()
7274
return;
7375
}
7476

75-
$graph->export($this->option('format'), $this->argument('filename'));
77+
$graph->export($this->option('format'), $this->getOutputFileName());
7678

7779
$this->info(PHP_EOL);
78-
$this->info('Wrote diagram to '.$this->argument('filename'));
80+
$this->info('Wrote diagram to ' . $this->getOutputFileName());
81+
}
82+
83+
protected function getOutputFileName(): string
84+
{
85+
return $this->argument('filename') ?:
86+
static::DEFAULT_FILENAME . '.' . $this->option('format');
7987
}
8088

8189
protected function getModelsThatShouldBeInspected(): Collection

0 commit comments

Comments
 (0)