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

Sort alternatives alphabetically when a command is not found#19887

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 2 commits intosymfony:masterfromjaviereguiluz:fix_10893
Mar 22, 2017

Conversation

@javiereguiluz
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#10893
LicenseMIT
Doc PR-

jameshalsall reacted with thumbs up emoji
@fabpot
Copy link
Member

As we are listing alternatives in a lot of different places in the framework, wouldn't it make sense to change the sort for all of them?

'afoobar',
'afoobar1',
'afoobar2',
'foo1:bar',
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 have expected foo1:bar to be after foo:bar as intuitively, I sort the namespace first, then the command name. Not sure if this is something we need to fix though.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's probably because of the: when sorting

Copy link
Member

Choose a reason for hiding this comment

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

I do understand that, my point is that we need to take care of that: when sorting like a human would do.

Copy link
MemberAuthor

@javiereguiluzjaviereguiluzSep 14, 2016
edited
Loading

Choose a reason for hiding this comment

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

The good thing is that in real apps we probably won't have this problem. This example (foo:,foo1:,foo3:) is too abstract and probably our users don't useproject:,project1: orapp:,app1: namespaces.

Copy link
Member

Choose a reason for hiding this comment

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

fair enough

@fabpot
Copy link
Member

Have you had time to have a look at the other exceptions using alternatives to see if sorting them would also make sense?

@ro0NL
Copy link
Contributor

ro0NL commentedSep 17, 2016
edited
Loading

I thought of this yesterday, and it's more or less related; wouldn't it be nice to filter the command list if a command is not found?

Ie.bin/console vs.bin/console keyword render the same output, but the latter only shows matching commands and some little info like"Showing 1 of 3 commands matching 'keyword'".

@fabpot
Copy link
Member

@javiereguiluz Any news?

@nicolas-grekasnicolas-grekas added this to the3.x milestoneDec 6, 2016
@fabpot
Copy link
Member

@javiereguiluz Still interested in finishing this PR?

@javiereguiluzjaviereguiluz self-assigned thisMar 1, 2017
@javiereguiluz
Copy link
MemberAuthor

Yes ... but I don't know where to look for more places where this feature could be implemented. Anyone can give me a clue? Thanks!

@fabpot
Copy link
Member

I think looking forlevenshtein in the code base would give you all the places where we need to make the same change.

@javiereguiluz
Copy link
MemberAuthor

I've committed some changes:

  • For the list of commands, I think that sorting best matches alphabetically is the most natural thing...
  • ... but for the other levenshtein candidates (service ids, param names, etc.) I propose to sort them from best to worst (i.e. from lowest to highest levenshtein distance)
linaori reacted with thumbs up emoji

if (false !==strpos($definedTag,$tag) ||levenshtein($tag,$definedTag) <=strlen($tag) /3) {
$candidates[] =$definedTag;
if (false !==strpos($definedTag,$tag) ||$lev =levenshtein($tag,$definedTag) <=strlen($tag) /3) {
$candidates[$definedTag] =$lev;
Copy link
Member

Choose a reason for hiding this comment

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

why not just$candidates[$definedTag] = true;? That would avoid creating the$lev variable that is not used anyway.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm not sure about this.$lev is the score ... and we need that for the two new lines added below to sort results from best to worst:

asort($candidates);$candidates =array_keys($candidates);

Copy link
Member

Choose a reason for hiding this comment

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

ok

@fabpot
Copy link
Member

Tests fail on deps=low, we should find a way to fix that.

@javiereguiluz
Copy link
MemberAuthor

I can't see which is the error that makes test fail for "deps = low". Can anyone help me? Thanks!


Some context --> The original test was:

Did you mean one of these: "bar", "baz"?

But after this PR, that fails on most Symfony versions, so I changed it to:

Did you mean one of these: "baz", "bar"?

and now test pass ... except when using "deps = low", which fails because the expected output is again:

Did you mean one of these: "bar", "baz"?

@linaori
Copy link
Contributor

@javiereguiluz my guess is that the DependencyInjection needs a higher console version for that as it seems like it's the DependencyInjection component that fails. I could be wrong though, but that's my hunch after seeing the failure.

@javiereguiluz
Copy link
MemberAuthor

After thinking about this, what if we do the following:

  1. Remove the last 3 commits
  2. Keep only the original feature that sorts commands alphabetically

Reason:

We already show very good alternatives because we limit the levenhstein cost to < 3, so every alternative displayed is almost as good as the other ones. The proposed changes wouldn't make the results much better.

What do you think?

@fabpot
Copy link
Member

Make sense 👍

@fabpot
Copy link
Member

Thank you@javiereguiluz.

@fabpotfabpot merged commitba6c946 intosymfony:masterMar 22, 2017
fabpot added a commit that referenced this pull requestMar 22, 2017
… found (javiereguiluz)This PR was squashed before being merged into the 3.3-dev branch (closes#19887).Discussion----------Sort alternatives alphabetically when a command is not found| Q | A || --- | --- || Branch? | master || Bug fix? | no || New feature? | yes || BC breaks? | no || Deprecations? | no || Tests pass? | yes || Fixed tickets |#10893 || License | MIT || Doc PR | - |Commits-------ba6c946 Sort commands like a human would dof04b1bd Sort alternatives alphabetically when a command is not found
@nicolas-grekasnicolas-grekas modified the milestones:3.x,3.3Mar 24, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

Assignees

@javiereguiluzjaviereguiluz

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

6 participants

@javiereguiluz@fabpot@ro0NL@linaori@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp