Skip to content

[Console] Show hidden commands in json & xml descriptors #21075

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

Merged
merged 1 commit into from
Jan 4, 2017
Merged

[Console] Show hidden commands in json & xml descriptors #21075

merged 1 commit into from
Jan 4, 2017

Conversation

ogizanagi
Copy link
Contributor

Q A
Branch? master
Bug fix? no (may be considered, but as hidden commands did not exist before 3.2, looks more like a behavior change, hence a feature)
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20866 (comment)
License MIT
Doc PR N/A

@ro0NL
Copy link
Contributor

ro0NL commented Dec 28, 2016

Nice 👍 what about bin/console list --show-hidden? The idea of hidden commands was to exclude them by default (for not having a contextual relevance).

@ogizanagi
Copy link
Contributor Author

Looks like an idea to me :)

But I'd like to keep meaningful defaults based on the format unless the --show-hidden flag is provided/explicitly set to true/false (InputOption::VALUE_OPTIONAL with default acting as auto).

Anyway, let's first approve this one before.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 28, 2016

meaningful defaults based on the format

Technically they dont know about each other.. they should not make assumptions regarding context imo. The only context we do have is "hidden", probably meaning; dont bother the user with it.

So 👍 for defaulting to false, where defaulting is needed. But i understand you actually chose to differ between XML/JSON and markdown here. Always providing the information technically in that case.

I think we should do format based decision making at command level. More close to real user decision making. Although it could still be experienced counter-intuitive. No real opinion here :)

Anyway, let's first approve this one before.

Im not sure you wanna do 2 PR's? But imo. it can be 1, doing the feature as a whole. Right now master is good (imo.); consistently hidden by default. Not sure we want this intermediate step, or as final solution for that matter, again imo.

For me 👍 adding --show-hidden to bypass the hardcoded default.

@ogizanagi
Copy link
Contributor Author

ogizanagi commented Dec 28, 2016

Im not sure you wanna do 2 PR's? But imo. it can be 1, doing the feature as a whole.

Just waiting for some more feedbacks on this and the option suggestion.

But ok, done.

@fabpot
Copy link
Member

fabpot commented Dec 28, 2016

I think I'm 👎 on the --show-hidden option. That would defeat the whole purpose of the hidden feature as accepted when it was introduced.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 28, 2016

Sounds reasonable. But it really depends what "hidden" means. Is it only from a end-user perspective? GUI-wise?

Then the initial (by now ;-)) approach makes sense. Including for technical formats, excluding for human formats.

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 basically only having the console option yes/no is questionable.

Status: Reviewed

$description = new ApplicationDescription($application, $namespace);
$namespace = isset($options['namespace']) ? $options['namespace'] : null;
$showHidden = isset($options['show_hidden']) ? $options['show_hidden'] : false;
$description = new ApplicationDescription($application, $namespace, $showHidden);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting a ApplicationDescription from options looks tedious..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? 😕

Copy link
Contributor

@ro0NL ro0NL Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptor::getApplicationDescription($options) could be worth it by now (2 options * 4 descriptors)

@@ -178,6 +178,15 @@ The output format (txt, xml, json, or md)
* Is multiple: no
* Default: `'txt'`

#### `--show-hidden`

To show hidden commands
Copy link
Contributor

@ro0NL ro0NL Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe To include hidden commands, it kinda implies we lose the other ones. Anyway this made me doubt between --show-hidden and --with-hidden. Im fine either way, but perhaps be explicit in its description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not. include indeed looks better to me :)

*/
public function __construct(Application $application, $namespace = null)
public function __construct(Application $application, $namespace = null, $showHidden = false)
Copy link
Contributor

@ro0NL ro0NL Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is good for sure 👍 same for updated outputs.

@@ -85,6 +86,7 @@ private function createDefinition()
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
new InputOption('show-hidden', null, InputOption::VALUE_NONE, 'To show hidden commands'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No opinion (as we can also use application descriptors in code, so as calling commands).

@ogizanagi
Copy link
Contributor Author

There is one more thing to consider regarding the --show-hidden option: It feels strange for both xml and json formats to get the hidden information always added as an attribute. If it doesn't include hidden commands, this is pretty useless.

I'll wait some more opinions and remove the option if it doesn't seem appropriated.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 28, 2016

Not sure, we wanna micro optimize that? The definition is clear, allowing everybody to rely on it consistently.

@@ -64,7 +64,7 @@ protected function describeCommand(Command $command, array $options = array())
protected function describeApplication(Application $application, array $options = array())
{
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
Copy link
Contributor

@ro0NL ro0NL Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion of getApplicationDescription was to move (global) option management to a single place. Keeping this doesnt solve that, gaining only 1 option * 4 descriptors.

Imo. we should rely on some $description->getNamespace() as of below, otherwise maybe revert.

@fabpot
Copy link
Member

fabpot commented Dec 30, 2016

"Then the initial (by now ;-)) approach makes sense. Including for technical formats, excluding for human formats." -> like that.

@ogizanagi
Copy link
Contributor Author

--show-hidden option removed :)

@@ -64,7 +64,7 @@ protected function describeCommand(Command $command, array $options = array())
protected function describeApplication(Application $application, array $options = array())
{
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
$description = new ApplicationDescription($application, $describedNamespace);
$description = new ApplicationDescription($application, $describedNamespace, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo. the descriptor option was nice :) anyway it's internal code.. we're good 👍

@nicolas-grekas nicolas-grekas added this to the 3.x milestone Jan 2, 2017
@fabpot
Copy link
Member

fabpot commented Jan 4, 2017

Thank you @ogizanagi.

@fabpot fabpot merged commit b6cf240 into symfony:master Jan 4, 2017
fabpot added a commit that referenced this pull request Jan 4, 2017
…rs (ogizanagi)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Console] Show hidden commands in json & xml descriptors

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no (may be considered, but as hidden commands did not exist before 3.2, looks more like a behavior change, hence a feature)
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20866 (comment)
| License       | MIT
| Doc PR        | N/A

Commits
-------

b6cf240 [Console] Show hidden commands in json & xml descriptors
@ogizanagi ogizanagi deleted the feature/console/show_hidden_cmd_json_xml branch January 4, 2017 14:30
@nicolas-grekas nicolas-grekas modified the milestone: 3.x Mar 24, 2017
@fabpot fabpot mentioned this pull request May 1, 2017
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.

5 participants