Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Add completion to help & list commands#43596

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.4fromGromNaN:complete/list-help
Oct 20, 2021

Conversation

@GromNaN
Copy link
Member

QA
Branch?5.4
Bug fix?no
New feature?yes
Deprecations?no
Tickets#43594
LicenseMIT
Doc PRno
  • Add completion for commandshelp andlist
  • Create a tester class to wrap completion code in tests
  • To autocomplete option--format, supported formats are exposed byDescriptorHelper

thrownew \LogicException(sprintf('Command "%s" must implement "%s" to support completion.',\get_class($this->command), CompletionInput::class));
}

$currentIndex =\count($input);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we make this a parameter (e.g. for cases where the suggestions for argument 1 is different based on argument 2?)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Please open a PR. The index thing is tricky and I don't know to deal with it.

@wouterj
Copy link
Member

Thank you for starting this initiative@GromNaN !

@fabpot
Copy link
Member

Thank you@GromNaN.


publicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void
{
if ($input->mustSuggestArgumentValuesFor('namespace')) {

Choose a reason for hiding this comment

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

Would it be an improvement to create a "Helper", in order to have common functions forcomplete and calling it like this:

publicfunctionshouldSuggestValues(string$type):void {if ($input->mustSuggestArgumentValuesFor($type)) {$descriptor =newApplicationDescription($this->getApplication());$suggestions->suggestValues(array_keys($descriptor->getNamespaces()));return;    }if ($input->mustSuggestOptionValuesFor('format')) {$helper =newDescriptorHelper();$suggestions->suggestValues($helper->getFormats());    }}

And calling it in thecomplete function forListCommand.php andHelpCommand.php?

// ListCommand.phppublicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void{$this->commandHelper->shouldSuggestValues('namespace');}
// HelpCommand.phppublicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void{$this->commandHelper->shouldSuggestValues('command_name');}

?

Copy link
Member

Choose a reason for hiding this comment

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

Having a helper knowing about argument names of all Symfony commands does not make sense (and would require to make argument names unique across all commands)

@BenjaminRbt
Copy link

Oups, didn't see it was already merged@GromNaN

I guess no need to take mycomment into account.

*
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
class CommandCompletionTester
Copy link
Member

Choose a reason for hiding this comment

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

I would make this one final

wouterj reacted with thumbs up emoji
@GromNaNGromNaN deleted the complete/list-help branchOctober 22, 2021 08:51
fabpot added a commit that referenced this pull requestOct 30, 2021
…, form, messenger, router (IonBazan)This PR was merged into the 5.4 branch.Discussion----------[Console] add suggestions for debug commands: firewall, form, messenger, router| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |#43594| License       | MIT| Doc PR        | -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 and `DescriptorHelper::getFormats()`.~Commits-------eaf9461 add suggestions for debug:firewall, debug:form, debug:messenger, debug:router
This was referencedNov 5, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@wouterjwouterjwouterj approved these changes

@chalasrchalasrchalasr left review comments

@fabpotfabpotfabpot approved these changes

+1 more reviewer

@BenjaminRbtBenjaminRbtBenjaminRbt left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@GromNaN@wouterj@fabpot@BenjaminRbt@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp