1

I am writing my first symfony console apps and I would like to ask a question regarding the console outputs.

When I run a new CLI app in the console like: ./testapp then I get the following output:

Usage:
 command [options] [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question

Available commands:
 help       Displays help for a command
 list       Lists commands

Is there a way to remove the display of this content? I want only the "Available Commands" to be visible. And is it possible to create my own groups in this display?

7
  • That make not so much sense to remove the Options. What would you do that? ;) That are the options for your current command. Commented Apr 4, 2015 at 12:13
  • 1
    Well.. I do not want to remove the options itself. Only the display when calling the app. So to clean up the view so to speak Commented Apr 4, 2015 at 12:14
  • I don't understand your problem ;) when you call your command correctly you don't get that output then your command is executed. Commented Apr 4, 2015 at 12:15
  • Well there is not really a problem... :) Of course my command gets called correctly. But when I just call ./testapp I see this informational screen with the Name of the Application and the content above. and there I want to have a cleaned up display, as I only want the see the available commands section Commented Apr 4, 2015 at 12:19
  • I don't think that this is possible because that make really no sense. The usage description on top depends on the informations under the Usage command. But perhaps anybody here knows a solution. Commented Apr 4, 2015 at 12:22

2 Answers 2

1

As of Symfony 2.5, you can change the default command (the command that's executed when no command name was specified). See for more information: http://symfony.com/doc/current/components/console/changing_default_command.html

The Console component will always run the ListCommand when no command name is passed. In order to change the default command you just need to pass the command name to the setDefaultCommand method.

Sign up to request clarification or add additional context in comments.

1 Comment

But he want only the one list with available commands and don't overwrite the complete command. Ok then he have to implement that but its a bit useless ^^ to override the output is cool if you work with that output to parse them for example..
0

(Symfony Console 4.1)

It's possible to remove the default options:

$options = $app->getDefinition()->getOptions();
unset($options['ansi']);
unset($options['no-interaction']);
unset($options['verbose']);
unset($options['help']);
unset($options['quiet']);
unset($options['version']);
unset($options['no-ansi']);
$app->getDefinition()->setOptions($options);

or just:

$app->getDefinition()->setOptions();

Options group will not show in the list command.

Although I don't know if this has any undesirable side effect.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.