nunomaduro / laravel-console-menu

🔘 Beautiful PHP CLI menus. Is a php-school/cli-menu wrapper for Laravel/Artisan Console Commands
MIT License
802 stars 40 forks source link

Set width to 100% #21

Open sandervankasteel opened 4 years ago

sandervankasteel commented 4 years ago

Hi!

Currently I'm experimenting with this package in combination with Laravel-Zero (awesome work on both them btw :+1: !) but I had a small question, I'm trying to build a menu which has a full height and full width. However I already saw that cli-menu doesn't support setting the height of a menu, so that's out of the question. But I am currently doing the following to achieve a full width menu;

Code example:

        $option = $this->menu('Pizza menu', [
            'Freshly baked muffins',
            'Freshly baked croissants',
            'Turnovers, crumb cake, cinnamon buns, scones',
        ])
            ->setWidth($this->menu()->getTerminal()->getWidth())
            ->open();

Is there a more readable way of achieving the same result ? If not, would you accept a PR which the same result with the following syntax?

Proposed syntax:

        $option = $this->menu('Pizza menu', [
            'Freshly baked muffins',
            'Freshly baked croissants',
            'Turnovers, crumb cake, cinnamon buns, scones',
        ])
            ->setFullWidth()
            ->open();