This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaww.php
47 lines (40 loc) · 1.53 KB
/
aww.php
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
<?php
use Addwiki\Cli\Commands\Config\ConfigList;
use Addwiki\Cli\Commands\Config\SetDefaultUser;
use Addwiki\Cli\Commands\Config\SetDefaultWiki;
use Addwiki\Cli\Commands\Config\Setup;
use Addwiki\Cli\Config\AppConfig;
use Symfony\Component\Console\Application;
/**
* Per https://github.com/guzzle/guzzle/blob/master/docs/faq.rst
* "Maximum function nesting level of '100' reached, aborting" is possible
* This error message comes specifically from the XDebug extension.
*/
ini_set( 'xdebug.max_nesting_level', 1000 );
// global variable to allow registering additional commands
// each callback should take a single parameter implementing ArrayAccess (the app config)
$GLOBALS['awwCommands'] = [];
if ( file_exists( __DIR__ . '/../../autoload.php' ) ) {
// addwiki is part of a composer installation
require_once __DIR__ . '/../../autoload.php';
} elseif ( file_exists( __DIR__ . '/../../vendor/autoload.php' ) ) {
// addwiki is part of the mono repo and symlinked..?
require_once __DIR__ . '/../../vendor/autoload.php';
} else {
// addwiki is just compser installed as itself?
require_once __DIR__ . '/vendor/autoload.php';
}
$awwConfig = new AppConfig( __DIR__ );
$awwApp = new Application( 'aww - addwiki cli tool' );
$awwApp->addCommands( [
new Setup( $awwConfig ),
new ConfigList( $awwConfig ),
new SetDefaultWiki( $awwConfig ),
new SetDefaultUser( $awwConfig ),
] );
foreach ( $GLOBALS['awwCommands'] as $callback ) {
if ( is_callable( $callback ) ) {
$awwApp->addCommands( call_user_func( $callback, $awwConfig ) );
}
}
$awwApp->run();