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

[spiral/console] Add InfoCommand for Displaying Project Information #966

Open
butschster opened this issue Aug 15, 2023 · 0 comments
Open
Assignees
Milestone

Comments

@butschster
Copy link
Member

The proposed feature aims to enhance the usability and convenience of the installed application by introducing a new console command named InfoCommand. This command will provide developers with a quick and easy way to access essential project information, promoting automation, consistency, and correctness in executing common tasks.

The command is implemented as a part of the Spiral\Console\Command\SequenceCommand class. This ensures that developers can easily perform additional tasks or include their custom information in the command's execution process. The core functionality of the command includes displaying pre-defined information and allowing extensibility.

Here is an example of such command

use Spiral\Console\Command\SequenceCommand;
use Psr\Container\ContainerInterface;
use Spiral\Boot\Environment\AppEnvironment;
use Spiral\Boot\Environment\DebugMode;
use Spiral\Console\Config\ConsoleConfig;
use Spiral\Console\Sequence\CommandSequence;

final class InfoCommand extends SequenceCommand
{
    protected const NAME = 'info';
    protected const DESCRIPTION = 'Project info';

    public function perform(ConsoleConfig $config, ContainerInterface $container): int
    {
        $this->info('Project info:');
        $this->newLine();

        return $this->runSequence($this->getSequences($config), $container);
    }

    public function getSequences(ConsoleConfig $config): \Generator
    {
        yield new CommandSequence('cycle:render');

        yield new CommandSequence('tokenizer:info');

        yield from $config->getSequence('info');
    }
}

The perform method executes the command sequence, displaying the project's core information and any additional data added by the developer.

The getSequences method provides developers with the ability to add existing console commands from the application or installed packages to the sequence. This allows for a flexible way to customize the information displayed based on the specific needs of the project.

Example Usage:

php app.php info

The proposed feature will add a valuable tool to the installed application, providing developers with an efficient way to access and display project information.

@butschster butschster added this to the 3.9 milestone Aug 15, 2023
@butschster butschster self-assigned this Aug 15, 2023
@butschster butschster modified the milestones: 3.9, 3.11 Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant