-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Yaml] Add lint:yaml command usage #6963
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
Conversation
3afbfb8
to
6e27d51
Compare
~~~~~~~~~~~~~~~~~ | ||
|
||
The syntax of YAML contents can be validated through the CLI using the | ||
:class:`Symfony\\Component\\Yaml\Command\\LintCommand` command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should mention the console component is required (not required by the YAML one, except in dev) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was expected.. ^^
Btw, how would you mention it? I thought about a caution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what is the best way to do it, nor where we can encounter similar cases in the components documentation... Simply adding a little sentence followed by:
composer require symfony/console
?
I quickly searched and found those documentations:
- https://github.com/symfony/symfony-docs/blob/master/console/command_in_controller.rst#showing-colorized-command-output
- https://github.com/symfony/symfony-docs/blob/master/setup/bundles.rst#look-for-deprecations-and-fix-them
- https://github.com/symfony/symfony-docs/blob/master/service_container/lazy_services.rst#installation
- https://github.com/symfony/symfony-docs/blob/master/components/form.rst#csrf-protection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, applied. Thank you
75b5639
to
c4376f1
Compare
👍 |
I'm not that sure about this. Fabien is right that this is a component and you must integrate it into your setup ... but at the same time, providing a command that you cannot use unless you build a Console application looks not very friendly for the developer. Could components provide their own commands, ready to use if you also use the Console component? |
@javiereguiluz My first thought was the same as yours but indeed, it's tricky. Having a I think providing access to commands in components is already a good thing, people who want to use it just have to copy-paste this snippet. Even if not ideal, that's not a big deal. shall I reopen symfony/symfony/pull/19916 for discussion and deciders opinion? |
I don't understand the last sentence of @javiereguiluz comments. We do provide the command, and it is ready to use with any console application. The snippet in this PR is just how you can create a standalone script that only validate yaml files. But most of the time, you just need to add this command to your pre-existing console app. |
a636897
to
4851a2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks @chalasr.
|
||
$ composer require symfony/console | ||
|
||
Create a script containing a console application: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a script containing a console application:
-> Create a console application with lint:yaml as its only command:
?
# or contents passed to STDIN | ||
$ cat path/to/file.yml | php lint.php | ||
|
||
The result will be written on STDOUT, default in TXT format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could replace this:
The result will be written on STDOUT, default in TXT format.
For a JSON output, use the ``format`` option:
By this:
The result is written to STDOUT and uses a plain text format by default.
Add the ``--format`` option to get the output in JSON format:
4851a2a
to
c4172ab
Compare
@javiereguiluz I applied your suggestions, thank you for them. |
Thank you @chalasr. |
…luz) This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #6963). Discussion ---------- [Yaml] Add lint:yaml command usage This documents symfony/symfony#19139 (merged on 3.2) and closes symfony/symfony#19916. Commits ------- ed4cb40 Remove an unneeded code directive 44b4ad0 Use `terminal` instead of `bash` for console code 78075c1 Yaml] Add lint:yaml command usage
Looks like gh failed :). Closing as merged. |
@chalasr I didn't merge |
This documents symfony/symfony#19139 (merged on 3.2) and closes symfony/symfony#19916.