From f62fa88c6823b77eac12d37a95e7b9e3d08e7331 Mon Sep 17 00:00:00 2001 From: Nick Sagona Date: Tue, 28 Jul 2015 11:25:43 -0500 Subject: [PATCH] Update the README.md file --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d3298f..2f6f5c5 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,26 @@ And, any of these invalid commands will produce the error output: The last example is not value because we made the argument value of the `edit` command required. -This is a pretty barebones example. Ideally, you could wire an application to +### Using a prompt + +You can also trigger a prompt to get information from the user. You can enforce +a certain set of options as well as whether or not they are case-sensitive: + +```php +$console = new Pop\Console\Console(); +$letter = $console->prompt( + 'Which is your favorite letter: A, B, C, or D? ', + ['A', 'B', 'C', 'D'], + true +); +echo 'Your favorite letter is ' . $letter . '.'; +``` + + ./pop + Which is your favorite letter: A, B, C, or D? B // <- User types 'B' + Your favorite letter is B. + +These are pretty basic example. Ideally, you could wire an application to use the console but setting routes, controllers and actions. Refer to the [Pop PHP Skeleton](https://github.com/popphp/popphp-skeleton) example application to see how to wire up a CLI-based application using Pop PHP.