-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoHelpers.php
51 lines (39 loc) · 1.35 KB
/
DemoHelpers.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
42
43
44
45
46
47
48
49
50
51
<?php
/**
* JBZoo Toolbox - Cli.
*
* This file is part of the JBZoo Toolbox project.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @see https://github.com/JBZoo/Cli
*/
declare(strict_types=1);
namespace DemoApp\Commands;
use JBZoo\Cli\CliCommand;
use function JBZoo\Cli\cli;
class DemoHelpers extends CliCommand
{
protected function configure(): void
{
$this
->setName('helpers')
->setDescription('Examples of new CLI helpers');
parent::configure();
}
protected function executeAction(): int
{
$yourName = $this->ask("What's your name?", 'idk');
cli("Your name is \"{$yourName}\"");
$yourSecret = $this->askPassword('New password?');
cli("Your secret is \"{$yourSecret}\"");
$selectedColor = $this->askOption('Choose your favorite color', ['Red', 'Blue', 'Yellow'], 1);
$colorAlias = \strtolower($selectedColor);
cli("Selected color is \"<{$colorAlias}>{$selectedColor}</{$colorAlias}>\"");
$isConfirmed = $this->confirmation('Are you ready to execute the script?');
cli('Is confirmed: ' . ($isConfirmed ? 'Yes' : 'No'));
return self::SUCCESS;
}
}