From 14aea5a1f0504de62b510659ee252860806a4f58 Mon Sep 17 00:00:00 2001 From: Antoine Augusti Date: Fri, 2 Oct 2015 19:09:42 +0200 Subject: [PATCH] Ask for confirmation when trying to run the DemoSeederCommand in production --- app/Console/Commands/DemoSeederCommand.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Console/Commands/DemoSeederCommand.php b/app/Console/Commands/DemoSeederCommand.php index 0994b3f4..111d1818 100644 --- a/app/Console/Commands/DemoSeederCommand.php +++ b/app/Console/Commands/DemoSeederCommand.php @@ -21,6 +21,8 @@ use CachetHQ\Cachet\Models\User; use DateInterval; use DateTime; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; +use Symfony\Component\Console\Input\InputOption; /** * This is the demo seeder command. @@ -29,6 +31,8 @@ use Illuminate\Console\Command; */ class DemoSeederCommand extends Command { + use ConfirmableTrait; + /** * The console command name. * @@ -50,6 +54,10 @@ class DemoSeederCommand extends Command */ public function fire() { + if (!$this->confirmToProceed()) { + return; + } + $this->seedComponentGroups(); $this->seedComponents(); $this->seedIncidents(); @@ -57,6 +65,8 @@ class DemoSeederCommand extends Command $this->seedMetrics(); $this->seedSettings(); $this->seedUsers(); + + $this->info('Database seeded with demo data successfully!'); } /** @@ -306,4 +316,16 @@ class DemoSeederCommand extends Command User::create($user); } } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ]; + } }