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

subMenu usage #32

Open loranger opened 2 years ago

loranger commented 2 years ago

Hi,

I try to add sub-menu, but failed. I already took a look at php-school/cli-menu, but can't figure out how make it work.

I tried to add a subItem, a subOption, a subMenu but in the worst case it failed, in the best, it asks for a CliMenuBuilder or a local CliMenu…

I think ther is little lack of documentation here regarding the specific features usage or the way we can use the cli-menu behind the wrapper.

Could you help me, please ?

simonovich commented 2 years ago

The library can be used in different ways. If you show your code, they will help you.

Here is a small example:

    public function handle()
    {
        $op = [
            'Freshly baked muffins',
            'Freshly baked croissants',
            'Turnovers, crumb cake, cinnamon buns, scones',
        ];

        $option = (new NunoMaduro\LaravelConsoleMenu\Menu('Pizza menu'));

        $option->addSubMenu('My Submenu Item', function () {});
        $option = $option->addOptions($op);

        echo $option->open();
        //$this->info("You have chosen the option number #$option");
    }