|
29 | 29 | $stdio->end(); |
30 | 30 | }); |
31 | 31 | $router->add('help', function () use ($stdio) { |
32 | | - $stdio->writeln('Use TAB-completion or use "exit"'); |
| 32 | + $stdio->write('Use TAB-completion or use "exit"' . PHP_EOL); |
33 | 33 | }); |
34 | 34 | $router->add('(echo | print) <words>...', function (array $args) use ($stdio) { |
35 | | - $stdio->writeln(implode(' ', $args['words'])); |
| 35 | + $stdio->write(implode(' ', $args['words']) . PHP_EOL); |
36 | 36 | }); |
37 | 37 | $router->add('printf <format> <args>...', function (array $args) use ($stdio) { |
38 | | - $stdio->writeln(vsprintf($args['format'],$args['args'])); |
| 38 | + $stdio->write(vsprintf($args['format'],$args['args']) . PHP_EOL); |
39 | 39 | }); |
40 | 40 |
|
41 | 41 | // autocomplete the following commands (at offset=0/1 only) |
42 | 42 | $readline->setAutocomplete(function ($_, $offset) { |
43 | 43 | return $offset > 1 ? array() : array('exit', 'quit', 'help', 'echo', 'print', 'printf'); |
44 | 44 | }); |
45 | 45 |
|
46 | | -$stdio->writeln('Welcome to this interactive demo'); |
| 46 | +$stdio->write('Welcome to this interactive demo' . PHP_EOL); |
47 | 47 |
|
48 | 48 | // react to commands the user entered |
49 | 49 | $stdio->on('line', function ($line) use ($router, $stdio, $readline) { |
|
57 | 57 | try { |
58 | 58 | $args = Arguments\split($line); |
59 | 59 | } catch (Arguments\UnclosedQuotesException $e) { |
60 | | - $stdio->writeln('Error: Invalid command syntax (unclosed quotes)'); |
| 60 | + $stdio->write('Error: Invalid command syntax (unclosed quotes)' . PHP_EOL); |
61 | 61 | return; |
62 | 62 | } |
63 | 63 |
|
|
69 | 69 | try { |
70 | 70 | $router->handleArgs($args); |
71 | 71 | } catch (NoRouteFoundException $e) { |
72 | | - $stdio->writeln('Error: Invalid command usage'); |
| 72 | + $stdio->write('Error: Invalid command usage' . PHP_EOL); |
73 | 73 | } |
74 | 74 | }); |
75 | 75 |
|
|
0 commit comments