Implement a central command line controller
Currently FLOW3 provides a command line interface through the flow3.sh bash script which has a fixed support for certain commands. This logic of this script should be extracted and improved so that we'll end up with very lean flow3.sh and flow3.bat scripts which just pass the command line arguments to a FLOW3CLI.php script.
The FLOW3CLI should allow for simple registration of additional commands so that third party packages can also take advantage of the interface. In the long run this script could also provide an interactive shell which allows for executing the available commands.
#1 Updated by Bastian Waidelich about 10 years ago
I've started playing around with a new FLOW3 subpackage "CLI". It could provide a simple API to allow interaction with the command line like
output(), outputLine(), prompt($message), registerCommand(Command $command), outputHelp()...
A "Command" knows about its allowed/required arguments and is associated with a package, controller & action. With those information the CLI script would be able to display some auto generated help- and input screen for all registered commands.
FLOW3s main CLI script (e.g.
FLOW3CLI.php) could make use of these classes and provide "hooks" for other packages to register their commands. But people could also write their own CLI scripts and make use of the "CLI helper". This is rather rough, but what do you think about it generally? Gotta play with it a bit more..
Regarding the interaction. Can someone please try, whether this works on Mac/Unix:
$stdin = fopen('php://stdin','r'); $input = fread($stdin, 1024); echo 'you\'ve entered "' . $input . '"';