Skip to content

Commit b59108c

Browse files
committed
Docs for addItems & setItems
1 parent 6fedd5f commit b59108c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ $menu->open();
417417

418418
#### Getting, Removing and Adding items
419419

420-
You can also interact with the menu items in an action:
420+
You can also interact with the menu items in an action. You can add, remove and replace items. If you do this, you
421+
will likely want to redraw the menu as well so the new list is rendered.
421422

422423
```php
423424
use PhpSchool\CliMenu\MenuItem\LineBreakItem;
@@ -429,7 +430,14 @@ $itemCallable = function (CliMenu $menu) {
429430
$menu->removeItem($item);
430431
}
431432

433+
//add single item
432434
$menu->addItem(new LineBreakItem('-'));
435+
436+
//add multiple items
437+
$menu->addItems([new LineBreakItem('-'), new LineBreakItem('*')]);
438+
439+
//replace all items
440+
$menu->setItems([new LineBreakItem('+'), new LineBreakItem('-')]);
433441

434442
$menu->redraw();
435443
};

0 commit comments

Comments
 (0)