-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This replaces the `cliupdate.php` script with a `symfony/console` based entry point: php bin/selfossctl update In the future we are going to introduce more commands. We are creating `LazyCommand`s manually because `Symfony\Component\Console\CommandLoader\ContainerCommandLoader` does not support lazy loading of commands. That appears to only be supported through Symfony’s DI container: https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description Specifically, regular commands are getting turned to lazy ones in `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass`. The individual commands cannot be more lazy so `selfossctl help update` will still connect to database.
- Loading branch information
Showing
11 changed files
with
774 additions
and
704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
// SPDX-FileCopyrightText: 2023 Jan Tojnar <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use Commands\UpdateCommand; | ||
use Psr\Container\ContainerInterface; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Command\LazyCommand; | ||
|
||
require __DIR__ . '/../src/common.php'; | ||
|
||
/** @var ContainerInterface $container */ | ||
$commands = [ | ||
UpdateCommand::class, | ||
]; | ||
|
||
$application = new Application(); | ||
|
||
// We cannot use ContainerCommandLoader because it does not support lazy loading. | ||
foreach ($commands as $command) { | ||
$name = $command::$defaultName; | ||
$description = $command::$defaultDescription; | ||
|
||
$lazyCommand = new LazyCommand( | ||
/* name: */ $name, | ||
/* aliases: */ [], | ||
/* description: */ $description, | ||
/* isHidden: */ false, | ||
fn() => $container->get($command) | ||
); | ||
$application->add($lazyCommand); | ||
} | ||
|
||
$application->run(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.