@@ -83,7 +83,7 @@ composer require php-school/cli-menu
83
83
## Upgrading
84
84
85
85
Please 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.
87
87
88
88
## Usage
89
89
@@ -165,6 +165,15 @@ php basic.php
165
165
#### Disabled Items & Submenus
166
166
<img width =" 600 " alt =" submenu " src =" https://cloud.githubusercontent.com/assets/2174476/19047849/868fa8c0-899b-11e6-9004-811c8da6d435.png " >
167
167
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
+
168
177
#### Flash Dialogue
169
178
<img width =" 600 " alt =" submenu " src =" https://cloud.githubusercontent.com/assets/2817002/19786090/1f07dad6-9c94-11e6-91b0-c20ab2e6e27d.png " >
170
179
@@ -311,17 +320,16 @@ $menu = ($builder = new CliMenuBuilder)
311
320
->build();
312
321
```
313
322
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).
317
325
318
326
``` php
319
327
<?php
320
328
321
329
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
322
330
323
331
$menu = ($builder = new CliMenuBuilder)
324
- ->setWidth($builder->getTerminal()->getWidth() - 2 * 2 )
332
+ ->setWidth($builder->getTerminal()->getWidth())
325
333
->setMargin(2)
326
334
->build();
327
335
```
@@ -367,8 +375,8 @@ $menu = (new CliMenuBuilder)
367
375
368
376
#### Margin
369
377
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.
372
380
373
381
Automatically center menu:
374
382
@@ -392,7 +400,7 @@ use PhpSchool\CliMenu\Builder\CliMenuBuilder;
392
400
393
401
$menu = (new CliMenuBuilder)
394
402
->setWidth(200)
395
- ->setMargin(5) //5 margin left
403
+ ->setMargin(5)
396
404
->build();
397
405
```
398
406
@@ -828,6 +836,8 @@ $menu = (new CliMenuBuilder)
828
836
$style->setUncheckedMarker('[○] ')
829
837
->setCheckedMarker('[●] ');
830
838
})
839
+ ->addCheckboxItem('Orange juice', function () {})
840
+ ->addCheckboxItem('Bread', function () {})
831
841
->build();
832
842
```
833
843
@@ -844,6 +854,8 @@ $menu = (new CliMenuBuilder)
844
854
$style->setUncheckedMarker('[ ] ')
845
855
->setCheckedMarker('[✔] ');
846
856
})
857
+ ->addRadioItem('Go shopping', function () {})
858
+ ->addRadioItem('Go camping', function () {})
847
859
->build();
848
860
```
849
861
@@ -853,7 +865,7 @@ You can optionally display some arbitrary text on the right hand side of an item
853
865
you indicate which items to display it on. We use it to display ` [COMPLETED] ` on completed exercises, where the menu lists
854
866
exercises for a workshop application.
855
867
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)
857
869
858
870
The third parameter to ` addItem ` is a boolean whether to show the item extra or not. It defaults to false.
859
871
@@ -1028,7 +1040,7 @@ use PhpSchool\CliMenu\Builder\CliMenuBuilder;
1028
1040
use PhpSchool\CliMenu\CliMenu;
1029
1041
1030
1042
$myCallback = function(CliMenu $menu) {
1031
- // Do something
1043
+ echo "Client 1\nClient 2\nClient 3\n";
1032
1044
};
1033
1045
1034
1046
$menu = (new CliMenuBuilder)
@@ -1060,7 +1072,7 @@ use PhpSchool\CliMenu\Builder\CliMenuBuilder;
1060
1072
use PhpSchool\CliMenu\CliMenu;
1061
1073
1062
1074
$myCallback = function(CliMenu $menu) {
1063
- // Do something
1075
+ echo "Client 1\nClient 2\nClient 3\n";
1064
1076
};
1065
1077
1066
1078
$menu = (new CliMenuBuilder)
@@ -1194,7 +1206,7 @@ use PhpSchool\CliMenu\CliMenu;
1194
1206
1195
1207
$itemCallable = function (CliMenu $menu) {
1196
1208
$result = $menu->askNumber()
1197
- ->setPrompt ('Enter your age')
1209
+ ->setPromptText ('Enter your age')
1198
1210
->setPlaceholderText(10)
1199
1211
->setValidationFailedText('Invalid age, try again')
1200
1212
->ask();
@@ -1412,11 +1424,6 @@ Once you get going you might just end up with something that looks a little like
1412
1424
You can see the construction code here for more clarity on how to perform advanced configuration:
1413
1425
[ PHP School] ( https://github.com/php-school/php-workshop/blob/3240d3217bbf62b1063613fc13eb5adff2299bbe/src/Factory/MenuFactory.php )
1414
1426
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
-
1420
1427
## Integrations
1421
1428
1422
1429
* [ Symfony Console] ( https://github.com/RedAntNL/console )
0 commit comments