-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathradio-item.php
41 lines (36 loc) · 1.3 KB
/
radio-item.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
use PhpSchool\CliMenu\Style\RadioStyle;
require_once(__DIR__ . '/../vendor/autoload.php');
$itemCallable = function (CliMenu $menu) {
echo $menu->getSelectedItem()->getText();
};
$menu = (new CliMenuBuilder)
->setTitle('Select a Language')
->addSubMenu('Compiled', function (CliMenuBuilder $b) use ($itemCallable) {
$b->setTitle('Compiled Languages')
->addRadioItem('Rust', $itemCallable)
->addRadioItem('Go', $itemCallable)
->addRadioItem('Java', $itemCallable)
->addRadioItems([
['C++', $itemCallable],
['C', $itemCallable]
])
;
})
->addSubMenu('Interpreted', function (CliMenuBuilder $b) use ($itemCallable) {
$b->setTitle('Interpreted Languages')
->modifyRadioStyle(function (RadioStyle $style) {
$style->setUncheckedMarker('[ ] ')
->setCheckedMarker('[✔] ');
})
->addRadioItem('PHP', $itemCallable)
->addRadioItem('Javascript', $itemCallable)
->addRadioItem('Ruby', $itemCallable)
->addRadioItem('Python', $itemCallable)
;
})
->build();
$menu->open();