Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a selfossctl CLI tool #1440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add a selfossctl CLI tool #1440

wants to merge 1 commit into from

Conversation

jtojnar
Copy link
Member

@jtojnar jtojnar commented Jun 15, 2023

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.

@netlify
Copy link

netlify bot commented Jun 15, 2023

Deploy Preview for selfoss ready!

Name Link
🔨 Latest commit 07b6cfb
🔍 Latest deploy log https://app.netlify.com/sites/selfoss/deploys/6599e94b6d18c30008009af9
😎 Deploy Preview https://deploy-preview-1440--selfoss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jtojnar jtojnar changed the title Add a selfoss CLI tool Add a selfossctl CLI tool Jun 15, 2023
@jtojnar jtojnar added this to the 2.20 milestone Jun 15, 2023
@jtojnar
Copy link
Member Author

jtojnar commented Jun 15, 2023

I do not really like Symfony console.

ContentLoader used transitively by UpdateCommand is obtaining a DatabaseConnection through dependency injection. As a result, every time selfossctl is run, it will attempt to connect to database.

It is possible to make loading the commands lazy using ContainerCommandLoader (if it were not buggy with slince/di) but because that does not have access to command descriptions, it will still require instantiating all commands when doing selfossctl list.

Now, Symfony Console also supports lazy command descriptions but I would either have to use Symfony’s DI container (regular commands are getting turned to lazy ones in AddConsoleCommandPass) or create LazyCommands manually (that’s what we are doing now).

And even then selfossctl help update still requires instantiating the command.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant