22 lines
		
	
	
		
			550 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			550 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use NoccyLabs\React\Shell\CommandHandler;
							 | 
						||
| 
								 | 
							
								use React\EventLoop\Loop;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								require_once __DIR__."/../vendor/autoload.php";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$shell = new NoccyLabs\React\Shell\Shell();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$commands = new CommandHandler();
							 | 
						||
| 
								 | 
							
								$commands->add('help', function ($args, $shell) {
							 | 
						||
| 
								 | 
							
								    $shell->write("This could be usage help :)\n");
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								$commands->on('notfound', function ($command, $shell) {
							 | 
						||
| 
								 | 
							
								    $shell->write("Command not found: {$command}. Try help\n");
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$shell->on('prompt', function ($shell) { 
							 | 
						||
| 
								 | 
							
								    $shell->setPrompt(date(">> ")); 
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								$shell->on('input', $commands);
							 |