-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-bootstrap.php
More file actions
48 lines (38 loc) · 1.86 KB
/
cli-bootstrap.php
File metadata and controls
48 lines (38 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare( strict_types = 1 );
! defined( 'THEWEBSOLVER_CODEGARAGE_PAYMENT_CARD_CLI' )
|| ( fwrite( STDERR, 'The Payment Card Cli package has already been initialized.' ) && die );
use TheWebSolver\Codegarage\Cli\Cli;
use TheWebSolver\Codegarage\Cli\Bootstrap;
use TheWebSolver\Codegarage\Cli\Container;
use TheWebSolver\Codegarage\Scraper\Interfaces\Scrapable;
use TheWebSolver\Codegarage\Scraper\Interfaces\TableTracer;
use TheWebSolver\Codegarage\PaymentCard\Tracer\WikiPaymentCardTracer;
use TheWebSolver\Codegarage\PaymentCard\Console\ScrapeWikiPaymentCard;
use TheWebSolver\Codegarage\PaymentCard\Service\WikiPaymentCardScrapingService;
registerMainBootstrapFileForPaymentCardCommands();
Bootstrap::commands(
action: loadContainerAndRunPaymentCardCommands( ... ),
packages: [
'main' => 'thewebsolver/payment-card',
'cli' => 'thewebsolver/payment-card-cli',
]
);
/** Loads main CLI package bootstrap file which in turn discovers composer autoloader & configures commands. */
function registerMainBootstrapFileForPaymentCardCommands( string $slash = DIRECTORY_SEPARATOR ): void {
require_once __DIR__ . "{$slash}vendor{$slash}thewebsolver{$slash}cli{$slash}bootstrap.php";
}
function loadContainerAndRunPaymentCardCommands( Bootstrap $bootstrap ): void {
define( 'THEWEBSOLVER_CODEGARAGE_PAYMENT_CARD_CLI', true );
define( 'THEWEBSOLVER_CODEGARAGE_PAYMENT_CARD_ROOT_PATH', $bootstrap->rootPath );
$bootstrap->loadDirectories();
$container = $bootstrap->config['container'] ?? new Container(
bindings: [ Cli::class => [ Cli::class, true ] ],
context: [
WikiPaymentCardScrapingService::class => [ TableTracer::class => WikiPaymentCardTracer::class ],
ScrapeWikiPaymentCard::class => [ Scrapable::class => WikiPaymentCardScrapingService::class ],
]
);
$bootstrap->config['commandLoader']->load( $container );
$container->get( Cli::class )->run();
}