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! 🚀
51
51
Once [ installed] ( #install ) , you can use the following code to present a prompt in a CLI program:
52
52
53
53
``` php
54
- $stdio = new Stdio();
54
+ <?php
55
55
56
+ require __DIR__ . '/vendor/autoload.php';
57
+
58
+ $stdio = new Clue\React\Stdio\Stdio();
56
59
$stdio->setPrompt('Input > ');
57
60
58
61
$stdio->on('data', function ($line) use ($stdio) {
@@ -76,7 +79,7 @@ It is responsible for orchestrating the input and output streams
76
79
by registering and forwarding the corresponding events.
77
80
78
81
``` php
79
- $stdio = new Stdio();
82
+ $stdio = new Clue\React\Stdio\ Stdio();
80
83
```
81
84
82
85
This class takes an optional ` LoopInterface|null $loop ` parameter that can be used to
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \Stdio \Stdio ;
4
3
use React \EventLoop \Loop ;
5
4
6
5
require __DIR__ . '/../vendor/autoload.php ' ;
7
6
8
- $ stdio = new Stdio ();
7
+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
9
8
10
9
$ stdio ->write ('Will print periodic messages until you submit anything ' . PHP_EOL );
11
10
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \Stdio \Stdio ;
4
-
5
3
require __DIR__ . '/../vendor/autoload.php ' ;
6
4
7
- $ stdio = new Stdio ();
8
-
5
+ $ stdio = new Clue \React \Stdio \Stdio ();
9
6
$ stdio ->setPrompt ('> ' );
10
7
11
8
// limit history to HISTSIZE env
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \Stdio \Stdio ;
4
- use Clue \Arguments ;
5
- use Clue \Commander \Router ;
6
- use Clue \Commander \NoRouteFoundException ;
7
-
8
3
require __DIR__ . '/../vendor/autoload.php ' ;
9
4
10
- $ stdio = new Stdio ();
5
+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
11
6
$ stdio ->setPrompt ('> ' );
12
7
13
8
// limit history to HISTSIZE env
21
16
}
22
17
23
18
// register all available commands and their arguments
24
- $ router = new Router ();
19
+ $ router = new Clue \ Commander \ Router ();
25
20
$ router ->add ('exit | quit ' , function () use ($ stdio ) {
26
21
$ stdio ->end ();
27
22
});
54
49
}
55
50
56
51
try {
57
- $ args = Arguments \split ($ line );
58
- } catch (Arguments \UnclosedQuotesException $ e ) {
52
+ $ args = Clue \ Arguments \split ($ line );
53
+ } catch (Clue \ Arguments \UnclosedQuotesException $ e ) {
59
54
$ stdio ->write ('Error: Invalid command syntax (unclosed quotes) ' . PHP_EOL );
60
55
return ;
61
56
}
67
62
68
63
try {
69
64
$ router ->handleArgs ($ args );
70
- } catch (NoRouteFoundException $ e ) {
65
+ } catch (Clue \ Commander \ NoRouteFoundException $ e ) {
71
66
$ stdio ->write ('Error: Invalid command usage ' . PHP_EOL );
72
67
}
73
68
});
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \Stdio \Stdio ;
4
-
5
3
require __DIR__ . '/../vendor/autoload.php ' ;
6
4
7
- $ stdio = new Stdio ();
5
+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
8
6
$ stdio ->setPrompt ('> ' );
9
7
10
8
// add some special key bindings
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \Stdio \Stdio ;
4
-
5
3
require __DIR__ . '/../vendor/autoload.php ' ;
6
4
7
- $ stdio = new Stdio ();
5
+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
8
6
9
7
$ value = 10 ;
10
8
$ stdio ->on ("\033[A " , function () use (&$ value , $ stdio ) {
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \Stdio \Stdio ;
4
-
5
3
require __DIR__ . '/../vendor/autoload.php ' ;
6
4
7
- $ stdio = new Stdio ();
5
+ $ stdio = new Clue \ React \ Stdio \ Stdio ();
8
6
$ stdio ->setPrompt ('Username: ' );
9
7
10
8
$ first = true ;
You can’t perform that action at this time.
0 commit comments