Skip to content

Conversation

@peterjaap
Copy link

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

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(); ```
@nunomaduro
Copy link
Owner

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

@peterjaap
Copy link
Author

Go for it! :)

@peterjaap
Copy link
Author

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

@peterjaap
Copy link
Author

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

@owenvoke
Copy link
Collaborator

owenvoke commented May 4, 2020

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?

* @return \NunoMaduro\LaravelConsoleMenu\Menu
*/
public function addOption($value, string $label): Menu
public function addOption($value, string $label, ?CliMenuBuilder $subMenu = null): Menu
Copy link
Owner

Choose a reason for hiding this comment

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

Hey buddy, why we need the , ?CliMenuBuilder $subMenu = null?

Copy link
Author

Choose a reason for hiding this comment

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

In the callback on line 92, I pass the Menu object so we can add options to the menu recursively.

Copy link
Author

Choose a reason for hiding this comment

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

I assigned the values to new variables to make it a bit clearer what's happening.

Copy link
Author

@peterjaap peterjaap May 20, 2020

Choose a reason for hiding this comment

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

@nunomaduro @owenvoke any further thoughts on this? Trying to get a decision on this before I release my book (June 1st) so I can scratch it or leave it in or change it (because I mention this in my chapter on the menu add-on).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey, sorry I seem to have a huge amount of notifications recently so think I missed this again. 🤦 Personally I think this seems fine.

Copy link
Author

Choose a reason for hiding this comment

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

Any new thoughts on this @nunomaduro ?

Copy link
Author

Choose a reason for hiding this comment

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

@nunomaduro fixed the merge conflict, good to go!

Copy link
Author

Choose a reason for hiding this comment

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

@nunomaduro i think your styleci might be misconfigured, it wants double spaces here;

image

Anyway, passes now. Weird.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Double spaces is the Laravel standard. Tbh, we should probably migrate to Pint here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants