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] Allow limiting the height of a console section#47308

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:6.2fromwouterj:console-section-height
Sep 29, 2022

Conversation

@wouterj
Copy link
Member

@wouterjwouterj commentedAug 17, 2022
edited
Loading

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
Doc PRtbd

This extends the Section feature of the Symfony console with the possibility to define a maximum height. The content will automatically "scroll up" when the content exceeds this height.

code used in this example
<?phpuseSymfony\Component\Console\Helper\ProgressBar;useSymfony\Component\Console\Input\InputInterface;useSymfony\Component\Console\Output\OutputInterface;useSymfony\Component\Console\SingleCommandApplication;useSymfony\Component\Console\Style\SymfonyStyle;useSymfony\Component\Console\Terminal;require_once'vendor/autoload.php';(newSingleCommandApplication())  ->setCode(function (InputInterface$input,OutputInterface$output):int {$output->writeln(['<comment>Testing sections','================</>','']);// section for log messages, set the max height to 3 lines$messageSection =$output->section();$messageSection->setMaxHeight(3);// section for the progress bar$progressSection =$output->section();$progressSection->writeln('');// run some heavy logic in 100 steps$progress =newProgressBar($progressSection);$progress->start(100);for ($i =0;$i <100;$i++) {if (0 ===$i %10) {$messageSection->write('   Message from step'.$i);      }elseif (0 ===$i %5) {$messageSection->writeln(' and'.$i);      }$progress->advance();usleep(50000);    }$progress->finish();// process finished, show all messages (i.e. remove height limitation)$messageSection->setMaxHeight(0);$progressSection->overwrite(['','<bg=green>  </> All steps completed successfully!','']);return SingleCommandApplication::SUCCESS;  })  ->run();

sf-overflow-sections

This terminal ui can be found in real world applications like the new Docker buildkit and Docker Compose V2. It's very useful to show verbose output in long running process, without taking over the complete terminal buffer.

welcoMattic, suasgn, arnissolle, sgc-fireball, alamirault, OskarStark, dadangnh, and machitgarha reacted with heart emoji
@carsonbotcarsonbot added this to the6.2 milestoneAug 17, 2022
@carsonbotcarsonbot changed the title[POC][Console] Add possibility to define maximum section height[Console] [POC] Add possibility to define maximum section heightAug 17, 2022
@wouterjwouterj changed the title[Console] [POC] Add possibility to define maximum section height[Console] [POC] Allow limiting the height of a console sectionAug 17, 2022
Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

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

I like it a lot!

@PhilETaylor
Copy link
Contributor

Can something "like this" be applied to "fix this"?#29746

@wouterjwouterj changed the title[Console] [POC] Allow limiting the height of a console section[Console] Allow limiting the height of a console sectionSep 28, 2022
@wouterj
Copy link
MemberAuthor

I've added some tests, this is ready now as far as I'm concerned.

@fabpot
Copy link
Member

Thank you@wouterj.

@fabpotfabpot merged commitb7bc764 intosymfony:6.2Sep 29, 2022
@wouterjwouterj deleted the console-section-height branchSeptember 29, 2022 19:36
@fabpotfabpot mentioned this pull requestOct 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

4 participants

@wouterj@PhilETaylor@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp