-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from php-school/inputs-new
Inputs
- Loading branch information
Showing
39 changed files
with
1,772 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use PhpSchool\CliMenu\CliMenu; | ||
use PhpSchool\CliMenu\CliMenuBuilder; | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
$itemCallable = function (CliMenu $menu) { | ||
$username = $menu->askText() | ||
->setPromptText('Enter username') | ||
->setPlaceholderText('alice') | ||
->ask(); | ||
|
||
$age = $menu->askNumber() | ||
->setPromptText('Enter age') | ||
->setPlaceholderText('28') | ||
->ask(); | ||
|
||
$password = $menu->askPassword() | ||
->setPromptText('Enter password') | ||
->ask(); | ||
|
||
var_dump($username->fetch(), $age->fetch(), $password->fetch()); | ||
}; | ||
|
||
$menu = (new CliMenuBuilder) | ||
->setTitle('User Manager') | ||
->addItem('Create New User', $itemCallable) | ||
->addLineBreak('-') | ||
->build(); | ||
|
||
$menu->open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use PhpSchool\CliMenu\CliMenu; | ||
use PhpSchool\CliMenu\CliMenuBuilder; | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
$itemCallable = function (CliMenu $menu) { | ||
$result = $menu->askNumber() | ||
->setPlaceholderText(10) | ||
->ask(); | ||
|
||
var_dump($result->fetch()); | ||
}; | ||
|
||
$menu = (new CliMenuBuilder) | ||
->setTitle('Basic CLI Menu') | ||
->addItem('Enter number', $itemCallable) | ||
->addItem('Second Item', $itemCallable) | ||
->addItem('Third Item', $itemCallable) | ||
->addLineBreak('-') | ||
->build(); | ||
|
||
$menu->open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use PhpSchool\CliMenu\CliMenu; | ||
use PhpSchool\CliMenu\CliMenuBuilder; | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
$itemCallable = function (CliMenu $menu) { | ||
$result = $menu->askPassword() | ||
->setPlaceholderText('') | ||
->setValidator(function ($password) { | ||
if ($password === 'password') { | ||
$this->setValidationFailedText('Password is too weak'); | ||
return false; | ||
} else if (strlen($password) <= 6) { | ||
$this->setValidationFailedText('Password is not long enough'); | ||
return false; | ||
} | ||
|
||
return true; | ||
}) | ||
->ask(); | ||
|
||
var_dump($result->fetch()); | ||
}; | ||
|
||
$menu = (new CliMenuBuilder) | ||
->setTitle('Basic CLI Menu') | ||
->addItem('Enter password', $itemCallable) | ||
->addItem('Second Item', $itemCallable) | ||
->addItem('Third Item', $itemCallable) | ||
->addLineBreak('-') | ||
->build(); | ||
|
||
$menu->open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use PhpSchool\CliMenu\CliMenu; | ||
use PhpSchool\CliMenu\CliMenuBuilder; | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
$itemCallable = function (CliMenu $menu) { | ||
$result = $menu->askText() | ||
->setPlaceholderText('Enter something here') | ||
->ask(); | ||
|
||
var_dump($result->fetch()); | ||
}; | ||
|
||
$menu = (new CliMenuBuilder) | ||
->setTitle('Basic CLI Menu') | ||
->addItem('Enter text', $itemCallable) | ||
->addItem('Second Item', $itemCallable) | ||
->addItem('Third Item', $itemCallable) | ||
->addLineBreak('-') | ||
->build(); | ||
|
||
$menu->open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.