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] Improve UX on not found namespace/command#20869

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:masterfromSeldaek:console_ux
Dec 13, 2016

Conversation

@Seldaek
Copy link
Member

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

This improves the DX/UX when you don't remember what a command is called.. Traditionally you get this message saying "command x is ambiguous (Y, Z or 6 more)" and if the one you are looking for is in the 6 more you are out of luck. You then have to run the console without arg again, get 50 commands displayed, then have to scroll up to find which one it is you meant.

With this patch you get all suggestions always, even with description, so you can make an informed decision right away. See before/after on the screenshot below.

image

ogizanagi, chalasr, yceruto, theofidry, hason, and staabm reacted with thumbs up emoji
@linaori
Copy link
Contributor

Seems a lot better! Is it possible to make a 2 column table (borderless) out of them so they align properly?

@Seldaek
Copy link
MemberAuthor

Yup, did it by hand because it's like 3 lines of code and the Table requires an output and all.. seemed overly complex for this.

image

@SeldaekSeldaekforce-pushed theconsole_ux branch 2 times, most recently from76ecf4d to70b3e00CompareDecember 11, 2016 13:53
$application->add(new \Foo2Command());

$expectedMsg ="The namespace\"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1";
$this->setExpectedException('Symfony\Component\Console\Exception\CommandNotFoundException',$expectedMsg);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you can use::class there instead of the string? As the target is master this should be alright

@nicolas-grekasnicolas-grekas added this to the3.x milestoneDec 12, 2016
$exact =in_array($name,$commands,true);
if (count($commands) >1 && !$exact) {
$suggestions =$this->getAbbreviationSuggestions(array_values($commands));
$usableWidth = ($this->terminal->getWidth() ?:60) -10;

Choose a reason for hiding this comment

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

getWidth always returns something, with a default of80

$abbrevs =array_values($commands);
$maxLen =0;
foreach ($abbrevsas$abbrev) {
$maxLen =max(strlen($abbrev),$maxLen);

Choose a reason for hiding this comment

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

you should useHelper::strlen to deal with UTF-8 properly

$abbrevs =array_map(function ($cmd)use ($commandList,$usableWidth,$maxLen) {
$abbrev =str_pad($cmd,$maxLen,'').''.$commandList[$cmd]->getDescription();

returnstrlen($abbrev) >$usableWidth ?substr($abbrev,0,$usableWidth -3).'...' :$abbrev;

Choose a reason for hiding this comment

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

Helper::strlen

@nicolas-grekasnicolas-grekas modified the milestones:3.3,3.xDec 12, 2016
@hason
Copy link
Contributor

What about combine with PR#19282?

@Seldaek
Copy link
MemberAuthor

Fixed feedback (I had to add a Helper::substr too, I hope that's ok).

@hason hmm yeah I guess if yours is merged it kinda makes this one obsolete anyway? I don't really have a preference, I guess this one is simpler but less powerful.

@fabpot
Copy link
Member

Thank you@Seldaek.

@fabpotfabpot merged commitaae5fb1 intosymfony:masterDec 13, 2016
fabpot added a commit that referenced this pull requestDec 13, 2016
…eldaek)This PR was merged into the 3.3-dev branch.Discussion----------[Console] Improve UX on not found namespace/command| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MITThis improves the DX/UX when you don't remember what a command is called.. Traditionally you get this message saying "command x is ambiguous (Y, Z or 6 more)" and if the one you are looking for is in the 6 more you are out of luck. You then have to run the console without arg again, get 50 commands displayed, then have to scroll up to find which one it is you meant.With this patch you get all suggestions always, even with description, so you can make an informed decision right away. See before/after on the screenshot below.![image](https://cloud.githubusercontent.com/assets/183678/21080350/c3d446ea-bfac-11e6-934b-ba3d7c3dd34d.png)Commits-------aae5fb1 Improve UX on not found namespace/command
@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

+2 more reviewers

@SimperfitSimperfitSimperfit approved these changes

@theofidrytheofidrytheofidry approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

8 participants

@Seldaek@linaori@hason@fabpot@nicolas-grekas@Simperfit@theofidry@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp