Skip to content

Commit 0d09ef0

Browse files
committed
Add note about manually adding go back and exit buttons
1 parent ab75278 commit 0d09ef0

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,26 @@ $menu = (new CliMenuBuilder)
348348
->build();
349349
```
350350

351-
Note: This will also disable the Go Back button for sub menus.
351+
Note: This will also disable the Go Back button for sub menus.
352+
353+
You can manually add exit and go back buttons using the following:
354+
355+
```php
356+
use PhpSchool\CliMenu\CliMenuBuilder;
357+
use PhpSchool\CliMenu\Action\ExitAction;
358+
use \PhpSchool\CliMenu\Action\GoBackAction;
359+
360+
require_once(__DIR__ . '/../vendor/autoload.php');
361+
362+
$menu = (new CliMenuBuilder)
363+
->disableDefaultItems()
364+
->addSubMenu('Super Sub Menu')
365+
->setTitle('Behold the awesomeness')
366+
->addItem('Return to parent menu', new GoBackAction) //add a go back button
367+
->end()
368+
->addItem('Leave this place now !', new ExitAction) //add an exit button
369+
->build();
370+
```
352371

353372
The marker displayed by the side of the currently active item can be modified, UTF-8 characters are supported.
354373
The marker for un-selected items can also be modified. If you want to disable it, just set it to a space character.

0 commit comments

Comments
 (0)