Skip to content

Commit edbe9a0

Browse files
dejuryJonathan Hafkamp
andauthored
Add --force to imports & exports (#216)
Co-authored-by: Jonathan Hafkamp <[email protected]>
1 parent efaa724 commit edbe9a0

File tree

8 files changed

+34
-24
lines changed

8 files changed

+34
-24
lines changed

src/Commands/ExportAssets.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ExportAssets extends Command
3030
*
3131
* @var string
3232
*/
33-
protected $signature = 'statamic:eloquent:export-assets';
33+
protected $signature = 'statamic:eloquent:export-assets {--force : Force the operation to run, with all questions yes}';
3434

3535
/**
3636
* The console command description.
@@ -70,7 +70,7 @@ private function usingDefaultRepositories(Closure $callback)
7070

7171
private function exportAssetContainers()
7272
{
73-
if (! $this->confirm('Do you want to export asset containers?')) {
73+
if (! $this->option('force') && ! $this->confirm('Do you want to export asset containers?')) {
7474
return;
7575
}
7676

@@ -96,7 +96,7 @@ private function exportAssetContainers()
9696

9797
private function exportAssets()
9898
{
99-
if (! $this->confirm('Do you want to export assets?')) {
99+
if (! $this->option('force') && ! $this->confirm('Do you want to export assets?')) {
100100
return;
101101
}
102102

src/Commands/ExportCollections.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ExportCollections extends Command
2929
*
3030
* @var string
3131
*/
32-
protected $signature = 'statamic:eloquent:export-collections';
32+
protected $signature = 'statamic:eloquent:export-collections {--force : Force the operation to run, with all questions yes}';
3333

3434
/**
3535
* The console command description.
@@ -70,7 +70,7 @@ private function usingDefaultRepositories(Closure $callback)
7070

7171
private function exportCollections()
7272
{
73-
if (! $this->confirm('Do you want to export collections?')) {
73+
if (! $this->option('force') && ! $this->confirm('Do you want to export collections?')) {
7474
return;
7575
}
7676

@@ -111,7 +111,7 @@ private function exportCollections()
111111

112112
private function exportCollectionTrees()
113113
{
114-
if (! $this->confirm('Do you want to export collection trees?')) {
114+
if (! $this->option('force') && ! $this->confirm('Do you want to export collection trees?')) {
115115
return;
116116
}
117117

src/Commands/ExportNavs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ExportNavs extends Command
2828
*
2929
* @var string
3030
*/
31-
protected $signature = 'statamic:eloquent:export-navs';
31+
protected $signature = 'statamic:eloquent:export-navs {--force : Force the operation to run, with all questions yes}';
3232

3333
/**
3434
* The console command description.
@@ -68,7 +68,7 @@ private function usingDefaultRepositories(Closure $callback)
6868

6969
private function exportNavs()
7070
{
71-
if (! $this->confirm('Do you want to export navs?')) {
71+
if (! $this->option('force') && ! $this->confirm('Do you want to export navs?')) {
7272
return;
7373
}
7474

@@ -91,7 +91,7 @@ private function exportNavs()
9191

9292
private function exportNavTrees()
9393
{
94-
if (! $this->confirm('Do you want to export nav trees?')) {
94+
if (! $this->option('force') && ! $this->confirm('Do you want to export nav trees?')) {
9595
return;
9696
}
9797

src/Commands/ExportTaxonomies.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ExportTaxonomies extends Command
2929
*
3030
* @var string
3131
*/
32-
protected $signature = 'statamic:eloquent:export-taxonomies';
32+
protected $signature = 'statamic:eloquent:export-taxonomies {--force : Force the operation to run, with all questions yes}';
3333

3434
/**
3535
* The console command description.
@@ -69,7 +69,7 @@ private function usingDefaultRepositories(Closure $callback)
6969

7070
private function exportTaxonomies()
7171
{
72-
if (! $this->confirm('Do you want to export taxonomies?')) {
72+
if (! $this->option('force') && ! $this->confirm('Do you want to export taxonomies?')) {
7373
return;
7474
}
7575

@@ -90,7 +90,7 @@ private function exportTaxonomies()
9090

9191
private function exportTerms()
9292
{
93-
if (! $this->confirm('Do you want to export terms?')) {
93+
if (! $this->option('force') && ! $this->confirm('Do you want to export terms?')) {
9494
return;
9595
}
9696

src/Commands/ImportAssets.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ImportAssets extends Command
2727
*
2828
* @var string
2929
*/
30-
protected $signature = 'statamic:eloquent:import-assets';
30+
protected $signature = 'statamic:eloquent:import-assets {--force : Force the operation to run, with all questions yes}';
3131

3232
/**
3333
* The console command description.
@@ -65,7 +65,7 @@ private function useDefaultRepositories()
6565

6666
private function importAssetContainers()
6767
{
68-
if (! $this->confirm('Do you want to import asset containers?')) {
68+
if (! $this->option('force') && ! $this->confirm('Do you want to import asset containers?')) {
6969
return;
7070
}
7171

@@ -82,7 +82,7 @@ private function importAssetContainers()
8282

8383
private function importAssets()
8484
{
85-
if (! $this->confirm('Do you want to import assets?')) {
85+
if (! $this->option('force') && ! $this->confirm('Do you want to import assets?')) {
8686
return;
8787
}
8888

src/Commands/ImportCollections.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ImportCollections extends Command
2525
*
2626
* @var string
2727
*/
28-
protected $signature = 'statamic:eloquent:import-collections';
28+
protected $signature = 'statamic:eloquent:import-collections {--force : Force the operation to run, with all questions yes}';
2929

3030
/**
3131
* The console command description.
@@ -78,8 +78,13 @@ private function usingDefaultRepositories(Closure $callback)
7878

7979
private function importCollections()
8080
{
81-
$importCollections = $this->confirm('Do you want to import collections?');
82-
$importCollectionTrees = $this->confirm('Do you want to import collections trees?');
81+
if (! $this->option('force')) {
82+
$importCollections = $this->confirm('Do you want to import collections?');
83+
$importCollectionTrees = $this->confirm('Do you want to import collections trees?');
84+
} else {
85+
$importCollections = true;
86+
$importCollectionTrees = true;
87+
}
8388

8489
$collections = CollectionFacade::all();
8590

src/Commands/ImportNavs.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ImportNavs extends Command
2626
*
2727
* @var string
2828
*/
29-
protected $signature = 'statamic:eloquent:import-navs';
29+
protected $signature = 'statamic:eloquent:import-navs {--force : Force the operation to run, with all questions yes}';
3030

3131
/**
3232
* The console command description.
@@ -63,8 +63,13 @@ private function useDefaultRepositories()
6363

6464
private function importNavs()
6565
{
66-
$importNavigations = $this->confirm('Do you want to import navs?');
67-
$importNavigationTrees = $this->confirm('Do you want to import nav trees?');
66+
if (! $this->option('force')) {
67+
$importNavigations = $this->confirm('Do you want to import navs?');
68+
$importNavigationTrees = $this->confirm('Do you want to import nav trees?');
69+
} else {
70+
$importNavigations = true;
71+
$importNavigationTrees = true;
72+
}
6873

6974
$navs = NavFacade::all();
7075

src/Commands/ImportTaxonomies.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ImportTaxonomies extends Command
2828
*
2929
* @var string
3030
*/
31-
protected $signature = 'statamic:eloquent:import-taxonomies';
31+
protected $signature = 'statamic:eloquent:import-taxonomies {--force : Force the operation to run, with all questions yes}';
3232

3333
/**
3434
* The console command description.
@@ -66,7 +66,7 @@ private function useDefaultRepositories()
6666

6767
private function importTaxonomies()
6868
{
69-
if (! $this->confirm('Do you want to import taxonomies?')) {
69+
if (! $this->option('force') && ! $this->confirm('Do you want to import taxonomies?')) {
7070
return;
7171
}
7272

@@ -86,7 +86,7 @@ private function importTaxonomies()
8686

8787
private function importTerms()
8888
{
89-
if (! $this->confirm('Do you want to import terms?')) {
89+
if (! $this->option('force') && ! $this->confirm('Do you want to import terms?')) {
9090
return;
9191
}
9292

0 commit comments

Comments
 (0)