From 2fb1f346a9c9631c31bea8bf8c032bf060054e9e Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Thu, 3 Mar 2022 22:55:57 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Work=20on=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Commands/Command.php | 22 +++++++++++ app/Commands/GetShow.php | 49 ++++++++++++++++++++++++ app/Commands/InspireCommand.php | 52 -------------------------- app/Exceptions/Quit.php | 8 ++++ config/commands.php | 1 + tests/Feature/Commands/GetShowTest.php | 7 ++++ tests/Feature/InspireCommandTest.php | 5 --- 7 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 app/Commands/Command.php create mode 100644 app/Commands/GetShow.php delete mode 100644 app/Commands/InspireCommand.php create mode 100644 app/Exceptions/Quit.php create mode 100644 tests/Feature/Commands/GetShowTest.php delete mode 100755 tests/Feature/InspireCommandTest.php diff --git a/app/Commands/Command.php b/app/Commands/Command.php new file mode 100644 index 0000000..e14d2db --- /dev/null +++ b/app/Commands/Command.php @@ -0,0 +1,22 @@ +error($quit->getMessage()); + + return $quit->getCode() > 0 ? $quit->getCode() : 1; + } + } +} diff --git a/app/Commands/GetShow.php b/app/Commands/GetShow.php new file mode 100644 index 0000000..240298b --- /dev/null +++ b/app/Commands/GetShow.php @@ -0,0 +1,49 @@ +line(json_encode($this->options())); + # $this->ask('What?'); + # throw new Quit('Nope', 5); + $files = $this->getFiles(); + if ($this->confirm('Do you wish to continue?', true)) { + $this->line(json_encode($files)); + } + + return static::SUCCESS; + } + + protected function getFiles(): array + { + $input = $this->option('input'); + if (empty($input)) { + throw new Quit('No files given'); + } + + $files = array_map(function (string $file) { + if (!file_exists($file)) { + throw new Quit("$file is not a valid file"); + } + + return realpath($file); + }, $input); + + return $files; + } +} diff --git a/app/Commands/InspireCommand.php b/app/Commands/InspireCommand.php deleted file mode 100644 index 20afdca..0000000 --- a/app/Commands/InspireCommand.php +++ /dev/null @@ -1,52 +0,0 @@ - -
Laravel Zero
- - Simplicity is the ultimate sophistication. - - - HTML); - } - - /** - * Define the command's schedule. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule - * @return void - */ - public function schedule(Schedule $schedule) - { - // $schedule->command(static::class)->everyMinute(); - } -} diff --git a/app/Exceptions/Quit.php b/app/Exceptions/Quit.php new file mode 100644 index 0000000..ccc00bc --- /dev/null +++ b/app/Exceptions/Quit.php @@ -0,0 +1,8 @@ +get('/'); + + $response->assertStatus(200); +}); diff --git a/tests/Feature/InspireCommandTest.php b/tests/Feature/InspireCommandTest.php deleted file mode 100755 index 58c71a1..0000000 --- a/tests/Feature/InspireCommandTest.php +++ /dev/null @@ -1,5 +0,0 @@ -artisan('inspire')->assertExitCode(0); -});