2023-07-09 16:37:39 +00:00
< ? php
use function DI\autowire , DI\create , DI\get ;
use Psr\Http\Message\ResponseInterface ;
use Mcnd\CLI\CliMiddleware ;
use Notes\CLI\CommandFetcher ;
2023-11-03 23:51:39 +00:00
use Lean\ { Factory , Lean };
2023-07-09 16:37:39 +00:00
return [
CommandFetcher :: class => function ( $c ) {
$fetcher = new CommandFetcher ( null , null , $c -> get ( 'cli.caching' ));
$fetcher -> setFolderList ( array_map ( function ( $item ) {
return $item ;
}, $c -> get ( Lean :: class ) -> getCli ()));
return $fetcher ;
},
CliMiddleware :: class => function ( $c ) {
return new CliMiddleware ( $c , $c -> get ( 'cli.response:default' ), $c -> get ( CommandFetcher :: class ));
},
'cli.response:default' => function ( $c ) {
return function () {
2023-11-03 23:51:39 +00:00
return Factory\HttpFactory :: createTextResponse ( " This is the default response from CLI middleware which indicates that no command were registered for this application. \n " );
2023-07-09 16:37:39 +00:00
};
},
];