diff --git a/src/Commands/ExportTaxonomies.php b/src/Commands/ExportTaxonomies.php index 5368c08e..7385b2a8 100644 --- a/src/Commands/ExportTaxonomies.php +++ b/src/Commands/ExportTaxonomies.php @@ -29,7 +29,10 @@ class ExportTaxonomies extends Command * * @var string */ - protected $signature = 'statamic:eloquent:export-taxonomies {--force : Force the export to run, with all prompts answered "yes"}'; + protected $signature = 'statamic:eloquent:export-taxonomies + {--force : Force the export to run, with all prompts answered "yes"} + {--only-taxonomies : Only export taxonomies} + {--only-terms : Only export terms}'; /** * The console command description. @@ -69,7 +72,7 @@ private function usingDefaultRepositories(Closure $callback) private function exportTaxonomies() { - if (! $this->option('force') && ! $this->confirm('Do you want to export taxonomies?')) { + if (! $this->shouldExportTaxonomies()) { return; } @@ -90,7 +93,7 @@ private function exportTaxonomies() private function exportTerms() { - if (! $this->option('force') && ! $this->confirm('Do you want to export terms?')) { + if (! $this->shouldExportTerms()) { return; } @@ -130,4 +133,18 @@ private function exportTerms() $this->newLine(); $this->info('Terms exported'); } + + private function shouldExportTaxonomies(): bool + { + return $this->option('only-taxonomies') + || ! $this->option('only-terms') + && ($this->option('force') || $this->confirm('Do you want to export taxonomies?')); + } + + private function shouldExportTerms(): bool + { + return $this->option('only-terms') + || ! $this->option('only-taxonomies') + && ($this->option('force') || $this->confirm('Do you want to export terms?')); + } }