src/Knight23.php
public function run($argc, $argv)
    {
        $this->addDefaultCommands();

        // @todo place better command parser here
        if ($argc == 1) {
            $run = $this->getDefaultCommand();
            $argv = [];
        } else {
            $run = $argv[1];
            $argv = array_slice($argv, 2);
        }

        $found = false;

        /** @var CommandInterface $command */
        foreach ($this->commands as $command) {
            // @todo prevent multiple commands having the same name (why?)
            if ($command->getName() == $run) {
                $command->run([], $argv);
                $found = true;
            }
        }

        // @todo more graceful end
        if (!$found) {
            echo "command unknown\n";
            // exit with error
            exit(1);
        }

        // this is running the react event loop, maybe this should run the actual commands too?
        $this->loop->run();
    }
public function run($argc, $argv)
    {
        $this->addDefaultCommands();

        // @todo place better command parser here
        if ($argc == 1) {
            $run = $this->getDefaultCommand();
            $argv = [];
        } else {
            $run = $argv[1];
            $argv = array_slice($argv, 2);
        }

        $found = false;

        /** @var CommandInterface $command */
        foreach ($this->commands as $command) {
            // @todo prevent multiple commands having the same name (why?)
            if ($command->getName() == $run) {
                $command->run([], $argv);
                $found = true;
            }
        }

        // @todo more graceful end
        if (!$found) {
            echo "command unknown\n";
            // exit with error
            exit(1);
        }

        // this is running the react event loop, maybe this should run the actual commands too?
        $this->loop->run();
    }
public function run ( $ argc , $ argv ) { $ this -> addDefaultCommands ( ) ; // @todo place better command parser here if ( $ argc == 1 ) { $ run = $ this -> getDefaultCommand ( ) ; $ argv = [ ] ; } else { $ run = $ argv [ 1 ] ; $ argv = array_slice ( $ argv , 2 ) ; } $ found = false ; /** @var CommandInterface $command */ foreach ( $ this -> commands as $ command ) { // @todo prevent multiple commands having the same name (why?) if ( $ command -> getName ( ) == $ run ) { $ command -> run ( [ ] , $ argv ) ; $ found = true ; } } // @todo more graceful end if ( ! $ found ) { echo "command unknown\n" ; // exit with error exit ( 1 ) ; } // this is running the react event loop, maybe this should run the actual commands too? $ this -> loop -> run ( ) ; }
execute the actuall run
execute the actuall run