@@ -83,7 +83,7 @@ composer require php-school/cli-menu
8383## Upgrading
8484
8585Please refer to the [ Upgrade Documentation] ( UPGRADE.md ) documentation to see what is required to upgrade your installed
86- ` cli-menu ` version. Especially from 2. * to 3.0, much has changed.
86+ ` cli-menu ` version.
8787
8888## Usage
8989
@@ -165,6 +165,15 @@ php basic.php
165165#### Disabled Items & Submenus
166166<img width =" 600 " alt =" submenu " src =" https://cloud.githubusercontent.com/assets/2174476/19047849/868fa8c0-899b-11e6-9004-811c8da6d435.png " >
167167
168+ #### Checkbox Items
169+ <img width =" 600 " alt =" checkbox " src =" https://user-images.githubusercontent.com/2817002/74604044-62cd9200-50ba-11ea-941f-377a51c9dcfd.png " >
170+ <img width =" 600 " alt =" checkbox-split " src =" https://user-images.githubusercontent.com/2817002/74604048-63febf00-50ba-11ea-9b20-39eb3a79989d.png " >
171+
172+ #### Radio Items
173+
174+ <img width =" 600 " alt =" radio " src =" https://user-images.githubusercontent.com/2817002/74604049-652fec00-50ba-11ea-8361-faf325245793.png " >
175+ <img width =" 600 " alt =" radio-split " src =" https://user-images.githubusercontent.com/2817002/74604050-65c88280-50ba-11ea-9ee0-d4ea654e5a87.png " >
176+
168177#### Flash Dialogue
169178<img width =" 600 " alt =" submenu " src =" https://cloud.githubusercontent.com/assets/2817002/19786090/1f07dad6-9c94-11e6-91b0-c20ab2e6e27d.png " >
170179
@@ -311,17 +320,16 @@ $menu = ($builder = new CliMenuBuilder)
311320 ->build();
312321```
313322
314- If you want to use the full width of the terminal and apply a margin you will need to perform a little calculation yourself
315- since we use a box model like the ` box-sizing: border-box; ` in CSS. The example below will use the full width of the terminal plus a margin of 2 on the
316- left and right sides:
323+ If you want to use the full width of the terminal and apply a margin, use the terminal width, and we will do the calculations
324+ automatically (shrink the width based on the margin).
317325
318326``` php
319327<?php
320328
321329use PhpSchool\CliMenu\Builder\CliMenuBuilder;
322330
323331$menu = ($builder = new CliMenuBuilder)
324- ->setWidth($builder->getTerminal()->getWidth() - 2 * 2 )
332+ ->setWidth($builder->getTerminal()->getWidth())
325333 ->setMargin(2)
326334 ->build();
327335```
@@ -367,8 +375,8 @@ $menu = (new CliMenuBuilder)
367375
368376#### Margin
369377
370- The margin can be customised as one value. It is only applied to the left side of the menu. It can also be
371- set automatically which will center the menu nicely in the terminal.
378+ The margin can be customised as one value. It can also be set automatically which will center the menu nicely in the
379+ terminal.
372380
373381Automatically center menu:
374382
@@ -392,7 +400,7 @@ use PhpSchool\CliMenu\Builder\CliMenuBuilder;
392400
393401$menu = (new CliMenuBuilder)
394402 ->setWidth(200)
395- ->setMargin(5) //5 margin left
403+ ->setMargin(5)
396404 ->build();
397405```
398406
@@ -828,6 +836,8 @@ $menu = (new CliMenuBuilder)
828836 $style->setUncheckedMarker('[○] ')
829837 ->setCheckedMarker('[●] ');
830838 })
839+ ->addCheckboxItem('Orange juice', function () {})
840+ ->addCheckboxItem('Bread', function () {})
831841 ->build();
832842```
833843
@@ -844,6 +854,8 @@ $menu = (new CliMenuBuilder)
844854 $style->setUncheckedMarker('[ ] ')
845855 ->setCheckedMarker('[✔] ');
846856 })
857+ ->addRadioItem('Go shopping', function () {})
858+ ->addRadioItem('Go camping', function () {})
847859 ->build();
848860```
849861
@@ -853,7 +865,7 @@ You can optionally display some arbitrary text on the right hand side of an item
853865you indicate which items to display it on. We use it to display ` [COMPLETED] ` on completed exercises, where the menu lists
854866exercises for a workshop application.
855867
856- Item Extra is currently limited to only ` \PhpSchool\CliMenu\MenuItem\SelectableItem ` .
868+ Item Extra is currently limited to only selectable items (menus, checkboxes & radios included)
857869
858870The third parameter to ` addItem ` is a boolean whether to show the item extra or not. It defaults to false.
859871
@@ -1028,7 +1040,7 @@ use PhpSchool\CliMenu\Builder\CliMenuBuilder;
10281040use PhpSchool\CliMenu\CliMenu;
10291041
10301042$myCallback = function(CliMenu $menu) {
1031- // Do something
1043+ echo "Client 1\nClient 2\nClient 3\n";
10321044};
10331045
10341046$menu = (new CliMenuBuilder)
@@ -1060,7 +1072,7 @@ use PhpSchool\CliMenu\Builder\CliMenuBuilder;
10601072use PhpSchool\CliMenu\CliMenu;
10611073
10621074$myCallback = function(CliMenu $menu) {
1063- // Do something
1075+ echo "Client 1\nClient 2\nClient 3\n";
10641076};
10651077
10661078$menu = (new CliMenuBuilder)
@@ -1194,7 +1206,7 @@ use PhpSchool\CliMenu\CliMenu;
11941206
11951207$itemCallable = function (CliMenu $menu) {
11961208 $result = $menu->askNumber()
1197- ->setPrompt ('Enter your age')
1209+ ->setPromptText ('Enter your age')
11981210 ->setPlaceholderText(10)
11991211 ->setValidationFailedText('Invalid age, try again')
12001212 ->ask();
@@ -1412,11 +1424,6 @@ Once you get going you might just end up with something that looks a little like
14121424You can see the construction code here for more clarity on how to perform advanced configuration:
14131425[ PHP School] ( https://github.com/php-school/php-workshop/blob/3240d3217bbf62b1063613fc13eb5adff2299bbe/src/Factory/MenuFactory.php )
14141426
1415- ## Docs Translations
1416- _ (This might not be kept up-to-date since it's a community translation)_
1417- See this doc in [ Brazilian Portuguese (pt_BR)] ( docs/pt_BR/README.md )
1418-
1419-
14201427## Integrations
14211428
14221429 * [ Symfony Console] ( https://github.com/RedAntNL/console )
0 commit comments