Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] Improve UX ConfigDebugCommand has not yaml component #48457

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

Conversation

alamirault
Copy link
Contributor

@alamirault alamirault commented Dec 3, 2022

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #48429
License MIT
Doc PR symfony/symfony-docs#...

Throw exception in order to improve UX when Yaml component is missing

Message is inspired by

throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Install "symfony/yaml" to use it.');

@carsonbot carsonbot added this to the 6.3 milestone Dec 3, 2022
@GromNaN
Copy link
Member

GromNaN commented Dec 4, 2022

The command could fallback to json when the Yaml class is not available, the format is very similar (a little more verbose). You can add an option format to make the switch, like we did in config:dump-reference.

@alamirault
Copy link
Contributor Author

and could fallback to json when the Yaml class is not available, the format is very similar (a little more verbose). You can add an option format to make the switch, like we did in config:dump-reference.

Indeed it's better to have option like other comment ! I will rework PR to add it

@alamirault alamirault force-pushed the feature/improve-ux-config-debug-command branch from e28c7a6 to 058f9f0 Compare December 5, 2022 19:29
@alamirault alamirault requested a review from OskarStark December 5, 2022 19:35
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Much better, thank you for following the suggestion.

The text can be improved, we need some help for that.

@alamirault alamirault force-pushed the feature/improve-ux-config-debug-command branch from df13bd9 to 6b47249 Compare December 6, 2022 18:51
@alamirault alamirault requested a review from GromNaN December 6, 2022 18:54
Copy link
Contributor

@kaznovac kaznovac left a comment

Choose a reason for hiding this comment

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

great work @alamirault

Comment on lines 60 to 61
The <info>--format</info> option specifies the format of the configuration,
this is either <comment>yaml</comment> or <comment>json</comment>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The <info>--format</info> option specifies the format of the configuration,
this is either <comment>yaml</comment> or <comment>json</comment>.
The <info>--format</info> option specifies the output format of the configuration,
this is either <comment>yaml</comment> or <comment>json</comment>.
When the option is not provided, <comment>yaml</comment> is used when the <comment>symfony/yaml</comment> component is available,
otherwise the <comment>json</comment> will be used.

maybe use the same dynamic getAvailableFormatOptions approach to generate available format options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I now use getAvailableFormatOptions, but don"t know a really adapt sentence.

When the option is not provided, yaml is used when the symfony/yaml component is available,

Not sure if this detail is needed in help

@carsonbot carsonbot changed the title Improve UX ConfigDebugCommand has not yaml component [FrameworkBundle] Improve UX ConfigDebugCommand has not yaml component Dec 15, 2022
@alamirault alamirault force-pushed the feature/improve-ux-config-debug-command branch from 01c07b0 to c7036fa Compare December 18, 2022 12:04
@chalasr chalasr force-pushed the feature/improve-ux-config-debug-command branch from c7036fa to b20fce5 Compare December 18, 2022 14:20
@chalasr
Copy link
Member

chalasr commented Dec 18, 2022

Thank you @alamirault.

@chalasr chalasr merged commit 6bf414c into symfony:6.3 Dec 18, 2022
@chalasr
Copy link
Member

chalasr commented Dec 18, 2022

I didn't open a documentation issue as I believe those commands are not documented there, but it would be nice if you could double-check 🙏

@alamirault alamirault deleted the feature/improve-ux-config-debug-command branch December 18, 2022 18:17
@fabpot fabpot mentioned this pull request May 1, 2023
@Toflar
Copy link
Contributor

Toflar commented May 4, 2023

We have some inconsistency here. If you use --format=json on debug:config now, you do not actually get machine readable JSON as there's still the headline:

bin/console debug:config framework --format=json

Current configuration for extension with alias "framework"
==========================================================

{
    "framework": {
        "router": {
            "resource": "kernel::loadRoutes",
            "type": "service",
            "enabled": true,
            "utf8": true,
...

Is this desired? Should we probably skip the headline when --format=json? Or is it meant to be there as fallback only? Also, if you run bin/console list --format=json you do not get pretty printed JSON. It's actually meant to be machine readable. /cc @aschempp

fabpot added a commit that referenced this pull request Jun 24, 2023
…onfig not possible (Toflar)

This PR was squashed before being merged into the 6.3 branch.

Discussion
----------

[FrameworkBundle] Fixed parsing new JSON output of debug:config not possible

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

See my comment to the original PR which introduced `debug:config --format=json`: #48457 (comment)

Currently, it's not possible to parse the JSON output (neither is the YAML) which makes `--format=json` kind of pointless. The argument against this - I guess - is that the JSON format was introduced to make the command independent from the YAML component but still, why is `--format` an option then?

So I guess by delivering an additional option, we can fix this issue and make it parsable.

(Maybe instead of having `--no-tilte` we should call it `parsable` in the first place so that if in the future there's something on top of the title, the option would still be valid?)

Commits
-------

a3e8560 [FrameworkBundle] Fixed parsing new JSON output of debug:config not possible
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Jun 24, 2023
…onfig not possible (Toflar)

This PR was squashed before being merged into the 6.3 branch.

Discussion
----------

[FrameworkBundle] Fixed parsing new JSON output of debug:config not possible

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

See my comment to the original PR which introduced `debug:config --format=json`: symfony/symfony#48457 (comment)

Currently, it's not possible to parse the JSON output (neither is the YAML) which makes `--format=json` kind of pointless. The argument against this - I guess - is that the JSON format was introduced to make the command independent from the YAML component but still, why is `--format` an option then?

So I guess by delivering an additional option, we can fix this issue and make it parsable.

(Maybe instead of having `--no-tilte` we should call it `parsable` in the first place so that if in the future there's something on top of the title, the option would still be valid?)

Commits
-------

a3e8560631 [FrameworkBundle] Fixed parsing new JSON output of debug:config not possible
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Jul 28, 2023
…onfig not possible (Toflar)

This PR was squashed before being merged into the 6.3 branch.

Discussion
----------

[FrameworkBundle] Fixed parsing new JSON output of debug:config not possible

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

See my comment to the original PR which introduced `debug:config --format=json`: symfony/symfony#48457 (comment)

Currently, it's not possible to parse the JSON output (neither is the YAML) which makes `--format=json` kind of pointless. The argument against this - I guess - is that the JSON format was introduced to make the command independent from the YAML component but still, why is `--format` an option then?

So I guess by delivering an additional option, we can fix this issue and make it parsable.

(Maybe instead of having `--no-tilte` we should call it `parsable` in the first place so that if in the future there's something on top of the title, the option would still be valid?)

Commits
-------

a3e8560631 [FrameworkBundle] Fixed parsing new JSON output of debug:config not possible
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.

debug:config command uses Yaml without checking for it's presence
9 participants