Skip to content

Commit

Permalink
Adds Taxonomy export arguments (#393)
Browse files Browse the repository at this point in the history
* Adds Taxonomy export options

* Fixes linted
  • Loading branch information
adampatterson authored Jan 6, 2025
1 parent 52df13a commit 137c7aa
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/Commands/ExportTaxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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?'));
}
}

0 comments on commit 137c7aa

Please sign in to comment.