From 1a8ceb1ad534a0a2031421d242b0ad10c053659f Mon Sep 17 00:00:00 2001 From: ilumos Date: Sat, 9 Dec 2017 01:05:15 +0000 Subject: [PATCH] Switching from console app class to full app class Old: Illuminate\Console\Application New: Illuminate\Foundation\Application To allow for loading of service providers --- lancache-autofill | 50 +++++++++++++++++++----------------------- src/Console/Kernel.php | 37 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 src/Console/Kernel.php diff --git a/lancache-autofill b/lancache-autofill index 5919263..a17a8c0 100755 --- a/lancache-autofill +++ b/lancache-autofill @@ -2,18 +2,9 @@ load(); $dotenv->required(['DOWNLOADS_DIRECTORY', 'STEAMCMD_PATH']); -// Set up the console app -$app = new Application(new Container, new Dispatcher, '5.5'); +// Create the application +$app = new Illuminate\Foundation\Application(realpath(__DIR__)); + +// Register the console kernel +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + Zeropingheroes\LancacheAutofill\Console\Kernel::class +); + +// Register the exception handler +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + Zeropingheroes\LancacheAutofill\Exceptions\Handler::class +); // Set up the SQLite database connection $capsule = new Capsule; @@ -34,20 +37,13 @@ $capsule->addConnection([ $capsule->setAsGlobal(); $capsule->bootEloquent(); -// Make commands available -$app->add(new InitialiseDatabase); -$app->add(new InitialiseDownloadsDirectory); +// Run the console application +$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); +$status = $kernel->handle( + $input = new ArgvInput, + new ConsoleOutput +); -$app->add(new Initialise); -$app->add(new UpdateAppList); -$app->add(new SearchApps); -$app->add(new QueueApp); -$app->add(new QueuePopularApps); -$app->add(new ShowQueue); -$app->add(new StartDownloading); -$app->add(new AuthoriseAccount); -$app->add(new Dequeue); -$app->add(new Requeue); - -// Run the console app -$app->run(new ArgvInput(), new ConsoleOutput()); \ No newline at end of file +// Send output to the console once finished +$kernel->terminate($input, $status); +exit($status); diff --git a/src/Console/Kernel.php b/src/Console/Kernel.php new file mode 100644 index 0000000..cc82ea7 --- /dev/null +++ b/src/Console/Kernel.php @@ -0,0 +1,37 @@ +