File tree Expand file tree Collapse file tree 7 files changed +15
-27
lines changed
Expand file tree Collapse file tree 7 files changed +15
-27
lines changed Original file line number Diff line number Diff line change @@ -51,8 +51,11 @@ Let's take these projects to the next level together! 🚀
5151Once [ installed] ( #install ) , you can use the following code to present a prompt in a CLI program:
5252
5353``` php
54- $stdio = new Stdio();
54+ <?php
5555
56+ require __DIR__ . '/vendor/autoload.php';
57+
58+ $stdio = new Clue\React\Stdio\Stdio();
5659$stdio->setPrompt('Input > ');
5760
5861$stdio->on('data', function ($line) use ($stdio) {
@@ -76,7 +79,7 @@ It is responsible for orchestrating the input and output streams
7679by registering and forwarding the corresponding events.
7780
7881``` php
79- $stdio = new Stdio();
82+ $stdio = new Clue\React\Stdio\ Stdio();
8083```
8184
8285This class takes an optional ` LoopInterface|null $loop ` parameter that can be used to
Original file line number Diff line number Diff line change 11<?php
22
3- use Clue \React \Stdio \Stdio ;
43use React \EventLoop \Loop ;
54
65require __DIR__ . '/../vendor/autoload.php ' ;
76
8- $ stdio = new Stdio ();
7+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
98
109$ stdio ->write ('Will print periodic messages until you submit anything ' . PHP_EOL );
1110
Original file line number Diff line number Diff line change 11<?php
22
3- use Clue \React \Stdio \Stdio ;
4-
53require __DIR__ . '/../vendor/autoload.php ' ;
64
7- $ stdio = new Stdio ();
8-
5+ $ stdio = new Clue \React \Stdio \Stdio ();
96$ stdio ->setPrompt ('> ' );
107
118// limit history to HISTSIZE env
Original file line number Diff line number Diff line change 11<?php
22
3- use Clue \React \Stdio \Stdio ;
4- use Clue \Arguments ;
5- use Clue \Commander \Router ;
6- use Clue \Commander \NoRouteFoundException ;
7-
83require __DIR__ . '/../vendor/autoload.php ' ;
94
10- $ stdio = new Stdio ();
5+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
116$ stdio ->setPrompt ('> ' );
127
138// limit history to HISTSIZE env
2116}
2217
2318// register all available commands and their arguments
24- $ router = new Router ();
19+ $ router = new Clue \ Commander \ Router ();
2520$ router ->add ('exit | quit ' , function () use ($ stdio ) {
2621 $ stdio ->end ();
2722});
5449 }
5550
5651 try {
57- $ args = Arguments \split ($ line );
58- } catch (Arguments \UnclosedQuotesException $ e ) {
52+ $ args = Clue \ Arguments \split ($ line );
53+ } catch (Clue \ Arguments \UnclosedQuotesException $ e ) {
5954 $ stdio ->write ('Error: Invalid command syntax (unclosed quotes) ' . PHP_EOL );
6055 return ;
6156 }
6762
6863 try {
6964 $ router ->handleArgs ($ args );
70- } catch (NoRouteFoundException $ e ) {
65+ } catch (Clue \ Commander \ NoRouteFoundException $ e ) {
7166 $ stdio ->write ('Error: Invalid command usage ' . PHP_EOL );
7267 }
7368});
Original file line number Diff line number Diff line change 11<?php
22
3- use Clue \React \Stdio \Stdio ;
4-
53require __DIR__ . '/../vendor/autoload.php ' ;
64
7- $ stdio = new Stdio ();
5+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
86$ stdio ->setPrompt ('> ' );
97
108// add some special key bindings
Original file line number Diff line number Diff line change 11<?php
22
3- use Clue \React \Stdio \Stdio ;
4-
53require __DIR__ . '/../vendor/autoload.php ' ;
64
7- $ stdio = new Stdio ();
5+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
86
97$ value = 10 ;
108$ stdio ->on ("\033[A " , function () use (&$ value , $ stdio ) {
Original file line number Diff line number Diff line change 11<?php
22
3- use Clue \React \Stdio \Stdio ;
4-
53require __DIR__ . '/../vendor/autoload.php ' ;
64
7- $ stdio = new Stdio ();
5+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
86$ stdio ->setPrompt ('Username: ' );
97
108$ first = true ;
You can’t perform that action at this time.
0 commit comments