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 title table#26933

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:masterfrommaidmaid:console-table-title
Jul 11, 2018
Merged

Conversation

@maidmaid
Copy link
Contributor

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

Why not just add a title to console tables? Inspired by the famous file managerMidnight Commander.

screenshot from 2018-04-15 20-16-26

ro0NL, linaori, yceruto, ogizanagi, javiereguiluz, jwage, DAcodedBEAT, einenlum, and sstok reacted with thumbs up emoji
TABLE
),
array(
'Boooooooooooooooooooooooooooooooooooooooooooooooooooooooooks',
Copy link
Contributor

Choose a reason for hiding this comment

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

what about truncating instead of ignoring?

fsevestre, maidmaid, and yceruto reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Indeed, it's better. Done.

* Example: <code>+-----+-----------+-------+</code>
*/
privatefunctionrenderRowSeparator(int$type =self::SEPARATOR_MID)
privatefunctionrenderRowSeparator(int$type =self::SEPARATOR_MID,$title =null)
Copy link
Contributor

Choose a reason for hiding this comment

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

string $title = null

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

return$this;
}

publicfunctionsetTitle($title):self
Copy link
Contributor

Choose a reason for hiding this comment

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

?string $title?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

@nicolas-grekasnicolas-grekas added this to the4.2 milestoneApr 15, 2018
'Boooooooooooooooooooooooooooooooooooooooooooooooooooooooooks',
'default',
<<<'TABLE'
+ Booooooooooooooooooooooooooooooooooooooooooooooooooooooo... +

Choose a reason for hiding this comment

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

What if we leave at least 1 separator character for long titles in the head? Instead of this:

+ Booooooooooooooooooooooooooooooooooooooooooooooooooooooo... +| ISBN          | Title                    | Author           |+---------------+--------------------------+------------------+| 99921-58-10-7 | Divine Comedy            | Dante Alighieri  || ...

This:

+- Booooooooooooooooooooooooooooooooooooooooooooooooooooo... -+| ISBN          | Title                    | Author           |+---------------+--------------------------+------------------+| 99921-58-10-7 | Divine Comedy            | Dante Alighieri  || ...

ro0NL, apfelbox, and maidmaid reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done. That looks much better!

}

/**
* Returns the text within a portion of a string, using mb_substr if it is available.

Choose a reason for hiding this comment

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

We could remove... using mb_substr if it is available from the description because it's an internal detail and in the PHPdoc we usually only explain what we do but not how we do that.

Also, the description is a bit confusingReturns the text within a portion of a string ... because the function name meansReplace a part of the given string...

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I had put themb_substr detail to be consistent with the others methods of this helper, but effectively, that isn't really useful, so it's deleted now.

About the description, I reworded toReplaces text within a portion of a string (the same description than in thePHP doc)

}

if (null !==$title) {
$lenT = Helper::strlenWithoutDecoration($formatter =$this->output->getFormatter(),$formattedTitle =sprintf($format =$this->style->getTitleFormat(),$title));

Choose a reason for hiding this comment

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

Let's use better variable names here to ease future maintenance. For example:

$lenT ->$titleTextLength$lenM ->$titleMarkupLength

jvasseur reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Renamed :)

@maidmaidmaidmaidforce-pushed theconsole-table-title branch 2 times, most recently from30a72f8 to47183edCompareApril 16, 2018 13:46
@fabpot
Copy link
Member

Would it make sense to allow the title to be at the bottom as well?

@maidmaid
Copy link
ContributorAuthor

@fabpot What do you mean by "at the bottom"? The second line of the header or the very last line of the table?

@fabpot
Copy link
Member

I was thinking about the last line of the table.

@maidmaid
Copy link
ContributorAuthor

IMO, shown the title only in the first line is enough.

@fabpot
Copy link
Member

Not sure I understand the "enough" part. I was thinking about letting the user choose between displaying the title at the top or at the bottom (depending on what you want to achieve, doing one or the other might make more sense).

@ro0NL
Copy link
Contributor

What aboutsetHeaderTitle +setFooterTitle? Agree a title at the bottom might be useful, e.g. pagination info or some resultset status text.

yceruto, maidmaid, and azjezz reacted with thumbs up emoji

@yceruto
Copy link
Member

Also sometimes the table is too big, showing the title in both places (top/bottom) would be nice, avoids scrolling.

@maidmaid
Copy link
ContributorAuthor

As suggested, I addedsetHeaderTitle() andsetFooterTitle() methods:

screenshot from 2018-04-24 10-21-30

ogizanagi, jvasseur, yceruto, apfelbox, azjezz, einenlum, rquadling, and sstok reacted with thumbs up emojieinenlum and sstok reacted with hooray emojiro0NL, ostrolucky, einenlum, and sstok reacted with heart emoji

return$this;
}

publicfunctionsetfooterTitle(?string$title):self
Copy link
Contributor

Choose a reason for hiding this comment

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

s/footer/Footer/

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done

return$this;
}

publicfunctionsetfooterTitle(?string$title):self
Copy link
Contributor

Choose a reason for hiding this comment

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

method should be renamed tosetFooterTitle

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done

/**
* Replaces text within a portion of a string.
*/
publicstaticfunctionsubstr_replace(string$string,string$replacement,int$start,int$length =null):string
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this actually complies with CS ... should we prefersubstrReplace() (givenstrlenWithoutDecoration also)

but i understand the reasoning.. i don't mind really :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Maybe, someone like@nicolas-grekas could help us here ?

Choose a reason for hiding this comment

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

the logic is used once: let's inline it instead of creating a new public method

chalasr reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Inlined!

returnsubstr_replace($string,$replacement,$start,$length);
}

returnmb_substr($string,0,$start).$replacement.mb_substr($string,$start +$length);
Copy link
Contributor

Choose a reason for hiding this comment

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

fromhttp://php.net/manual/en/function.substr-replace.php

i think we should default$length = strlen($string); here as well

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

That looks working as expectedhttps://3v4l.org/C5Nhs, do I miss something ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like PHP treatsnull asint(0) 🤔

https://3v4l.org/f02sM

* Helper is the base class for all helper classes.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Dany Maillard <danymaillard93b@gmail.com>

Choose a reason for hiding this comment

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

can be removed now

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Oops, I just removed it.

@fabpot
Copy link
Member

Thank you@maidmaid.

@fabpotfabpot merged commit6bf9eeb intosymfony:masterJul 11, 2018
fabpot added a commit that referenced this pull requestJul 11, 2018
This PR was merged into the 4.2-dev branch.Discussion----------[Console] Add title table| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | /| License       | MIT| Doc PR        | /Why not just add a title to console tables? Inspired by the famous file manager [Midnight Commander](https://en.wikipedia.org/wiki/Midnight_Commander).![screenshot from 2018-04-15 20-16-26](https://user-images.githubusercontent.com/4578773/38777361-eb6aaa72-40e9-11e8-8ae4-055fe80272c3.png)Commits-------6bf9eeb Add title table
@maidmaidmaidmaid deleted the console-table-title branchJuly 11, 2018 10:00
@javiereguiluz
Copy link
Member

I've createdsymfony/symfony-docs#10294 to not forget about adding the docs for this feature.@maidmaid it'd be great if you could help us with the docs for this feature. Thanks!

@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
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

@fabpotfabpotfabpot approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

+2 more reviewers

@ro0NLro0NLro0NL requested changes

@azjezzazjezzazjezz approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

8 participants

@maidmaid@fabpot@ro0NL@yceruto@javiereguiluz@nicolas-grekas@azjezz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp