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

[Console] Show Application-level console options when showing synopsis or when error occurred #47436

Open
wants to merge 11 commits into
base: 7.1
Choose a base branch
from

Conversation

jlslew
Copy link

@jlslew jlslew commented Aug 30, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #42765
License MIT
Doc PR symfony/symfony-docs#...
BC Break I think yes

Create a file in the root directory of a Symfony project with the following code, then run php FILENAME echo --help --format FORMAT

#!/usr/bin/env php
<?php

require __DIR__ . '/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

$application = new Application('jlslew', '1.0.0');

$application->add(new class extends Command {
    protected function configure(): void
    {
        $this->setName('echo')
            ->setDescription('The description of the command')
            ->addArgument('argument', InputArgument::REQUIRED, 'The argument to execute')
            ->addOption('option', mode: InputOption::VALUE_REQUIRED, description: 'The option to execute');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln('Hello World!');
        return 0;
    }
});

$application->run();

EDIT: It might break BC because methods' signature has been changed (Added an argument with a default value)

@carsonbot
Copy link

Hey!

I think @mdeboer has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@OskarStark OskarStark changed the title [Console] Feature/42765 Show Application-level console options when showing synopsis or when error occured [Console] Show Application-level console options when showing synopsis or when error occurred Sep 8, 2022
@nicolas-grekas nicolas-grekas modified the milestones: 6.2, 6.3 Nov 5, 2022
@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 May 23, 2023
@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
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.

Show Application-level console options when showing synopsis or when error occured
3 participants