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

Add support for submenu #25

Open peterjaap opened 4 years ago

peterjaap commented 4 years ago

Using the proposed change, we can add a submenu by making a multi-dimensional array;

$options = [
    'House' => [
        123 => 'Task 1',
        124 => 'Task 2',
        125 => 'Task 3',
        126 => 'Task 4',
    ],
    'Car' => [
        200 => 'Task 5',
        201 => 'Task 6',
        202 => 'Task 7',
        203 => 'Task 8',
    ]
];

$taskId = $this->menu('Select task from category', $options)->open();

dd($taskId);

image

image

image

nunomaduro commented 4 years ago

The idea is a good, but I think we do better on the public api you provided. cc @owenvoke

peterjaap commented 4 years ago

Go for it! :)

peterjaap commented 4 years ago

@nunomaduro @owenvoke do you have any guidelines on how to do better on the public api? Any suggestions?

peterjaap commented 4 years ago

@nunomaduro @owenvoke maybe it's an idea to merge this as long there is no better idea for a public api?

owenvoke commented 4 years ago

Hi, sorry I'm not sure how I completely missed this until now. 😬 I can't personally think of a better API at the moment, what sort of thing were you thinking of @nunomaduro?