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

How to set the command help #37

Open
tacman opened this issue Oct 2, 2022 · 4 comments
Open

How to set the command help #37

tacman opened this issue Oct 2, 2022 · 4 comments

Comments

@tacman
Copy link
Contributor

tacman commented Oct 2, 2022

bin/console my:command --help 
bin/console make:crud --help 

Symfony's make:crud shows some help lines at the bottom, how is that set in an invokable command? I tried adding this to __invoke, but it didn't seem to work (although again, it might be related to lazy-loading).

        $this
            // the command help shown when running the command with the "--help" option
            ->setHelp('This is the help, not the description, and can be multiple lines.');
@tacman
Copy link
Contributor Author

tacman commented Oct 2, 2022

Ah, I had put it in the wrong spot, it needs to be set in configure()

    public function configure(): void
    {
        $this->setHelp("This is the help for my:command");
    }

@tacman
Copy link
Contributor Author

tacman commented Oct 3, 2022

What do you think about a class attribute for help, so as to avoid calling this,

#[AsCommand('my:command', 'From the extra-console documentation')]
#[CommandHelp(help: 'This is the help for my:command']
final class MyCommand extends InvokableServiceCommand

Of course, looking at this I have to wonder if this shouldn't just be added to the AsCommand attribute.

With an attribute in this class, what about having the option of passing in a filename? Symfony puts the help in separate files:

image

@tacman tacman reopened this Oct 3, 2022
@kbond
Copy link
Member

kbond commented Oct 3, 2022

Yeah, that could indeed be useful!

@kbond
Copy link
Member

kbond commented Dec 6, 2022

What do you think about proposing for AsCommand itself in Symfony?

#[AsCommand('my:command', help: __DIR__.'/..')]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants