-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] add suggestions for debug commands: firewall, form, messenger, router #43598
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
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
623af59
to
70fdfe3
Compare
Hey! I think @TimoBakx has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
70fdfe3
to
5c34db4
Compare
The |
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.
Very nice, especially on debug:form
.
Namespace backslash are missing from completion.
$ bin/console debug:form
AppFormCommentType SymfonyComponentFormExtensionCoreTypeCheckboxType SymfonyComponentFormExtensionCoreTypeEmailType SymfonyComponentFormExtensionCoreTypePasswordType SymfonyComponentFormExtensionCoreTypeTextType
AppFormPostType SymfonyComponentFormExtensionCoreTypeChoiceType SymfonyComponentFormExtensionCoreTypeFileType SymfonyComponentFormExtensionCoreTypePercentType SymfonyComponentFormExtensionCoreTypeTextareaType
AppFormTypeChangePasswordType SymfonyComponentFormExtensionCoreTypeCollectionType SymfonyComponentFormExtensionCoreTypeFormType SymfonyComponentFormExtensionCoreTypeRadioType SymfonyComponentFormExtensionCoreTypeTimeType
AppFormTypeDateTimePickerType SymfonyComponentFormExtensionCoreTypeColorType SymfonyComponentFormExtensionCoreTypeHiddenType SymfonyComponentFormExtensionCoreTypeRangeType SymfonyComponentFormExtensionCoreTypeTimezoneType
AppFormTypeTagsInputType SymfonyComponentFormExtensionCoreTypeCountryType SymfonyComponentFormExtensionCoreTypeIntegerType SymfonyComponentFormExtensionCoreTypeRepeatedType SymfonyComponentFormExtensionCoreTypeUrlType
AppFormUserType SymfonyComponentFormExtensionCoreTypeCurrencyType SymfonyComponentFormExtensionCoreTypeLanguageType SymfonyComponentFormExtensionCoreTypeResetType SymfonyComponentFormExtensionCoreTypeWeekType
SymfonyBridgeDoctrineFormTypeEntityType SymfonyComponentFormExtensionCoreTypeDateIntervalType SymfonyComponentFormExtensionCoreTypeLocaleType SymfonyComponentFormExtensionCoreTypeSearchType
SymfonyComponentFormExtensionCoreTypeBirthdayType SymfonyComponentFormExtensionCoreTypeDateTimeType SymfonyComponentFormExtensionCoreTypeMoneyType SymfonyComponentFormExtensionCoreTypeSubmitType
SymfonyComponentFormExtensionCoreTypeButtonType SymfonyComponentFormExtensionCoreTypeDateType SymfonyComponentFormExtensionCoreTypeNumberType SymfonyComponentFormExtensionCoreTypeTelType
Option completion is very accurate with a class:
$ bin/console debug:form App\Form\CommentType
action block_name csrf_message disabled getter invalid_message label_html priority trim
allow_extra_fields block_prefix csrf_protection empty_data help invalid_message_parameters label_translation_parameters property_path upload_max_size_message
allow_file_upload by_reference csrf_token_id error_bubbling help_attr is_empty_callback legacy_error_messages required validation_groups
attr compound csrf_token_manager error_mapping help_html label mapped row_attr
attr_translation_parameters constraints data extra_fields_message help_translation_parameters label_attr method setter
auto_initialize csrf_field_name data_class form_attr inherit_data label_format post_max_size_message translation_domain
But fails if backslashes are escaped. I don't know if that should be supported:
$ bin/console debug:form App\\Form\\CommentType
RuntimeException: The autoloader expected class "App\\Form\\CommentType" to be defined in file "src//Form//CommentType.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
@GromNaN these missing backslashes seem like an issue with the completion command escaping itself and input escaping. The suggestions provided by the |
Same issue with backslashes in #43653. |
I've proposed a (quite ugly) fix for the backslashes: #43664 I welcome more testers of this script, as I'm not sure how well this actually works (it works on my machine™) |
@GromNaN please review again |
LGTM. I used this PR to test #43665 and it worked very well. Regarding class types, the short names could have been completed in case someone type "ButtonType" for example. But name conflicts can appear and the completion made the FQCN lot easier to type. |
71620f3
to
cc315d4
Compare
cc315d4
to
eaf9461
Compare
Thank you @IonBazan. |
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Console] Fix backslash escaping in bash completion | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #43664 | License | MIT | Doc PR | - Fully tested code with #43598 - `printf` options `%b` and `%q` are handy to escape string using in shell input. - Backslashes must to be escaped (doubled) in normal input (`bin/console debug:form App\\Form\\CommentType`). Otherwise they are dropped when PHP receive the argument (`App\Form\CommentType` become `AppFormCommentType` in `$SERVER['argv']`). This is not necessary for quoted arguments (`bin/console debug:form "App\Form\CommentType"` is OK). In the context of a command stored in a variable, like in the bash script, escaping is not interpreted: we must replace `\\` by `\` using `printf '%b'`. - Completion does not process escaping. If `App\\Form\\` is typed, the suggestions must contain a `\\` to match. Since these values are provided to shell, double backslash must be escaped: `\` becomes `\\\\` in suggestion output. - I choose to detect when quotes are typed to allow them in completion and add quotes to suggestions. - Suggestion with spaces are still not properly working. https://user-images.githubusercontent.com/400034/138536102-e282ee75-56c8-414b-8b16-7c3c290276d7.mov Commits ------- e9e0c07 [Console] Fix backslash escaping in bash completion
Adding Bash completion for following commands:
debug:firewall
debug:form
debug:messenger
debug:router
Waiting for #43596 to be merged first as it adds testing utilities andDescriptorHelper::getFormats()
.