Skip to content

Commit 52f794c

Browse files
committed
restructure cli + commands, various fixes (relative dir bugs)
1 parent 202643e commit 52f794c

11 files changed

Lines changed: 33 additions & 33 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
class Helpers
66
{
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// must be run via web server.
44
// provides information regarding permissions and other things that can't be determined via CLI.
55

6-
namespace ob\tools\cli;
6+
namespace OpenBroadcaster\CLI;
77

88
if (php_sapi_name() === 'cli') {
99
die('This tool must not be run via the command line.' . PHP_EOL);
@@ -12,8 +12,8 @@
1212
// required to bypass components.php verify install
1313
define('OB_CLI', true);
1414

15-
require_once(__DIR__ . '/../../../core/init.php');
16-
require_once(__DIR__ . '/../../../public/updates/checker.php');
15+
require_once(__DIR__ . '/../../core/init.php');
16+
require_once(__DIR__ . '/../../public/updates/checker.php');
1717

1818
$system_user = exec('whoami');
1919

File renamed without changes.

tools/cli/ob.php renamed to cli/ob.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// command line tool (alpha)
77

8-
namespace ob\tools\cli;
8+
namespace OpenBroadcaster\CLI;
99

1010
define('OB_CLI', true);
1111

@@ -15,15 +15,15 @@
1515
die('This tool can only be used from the command line.');
1616
}
1717

18-
if (!file_exists(__DIR__ . '/../../config.php')) {
18+
if (!file_exists(__DIR__ . '/../config.php')) {
1919
die('Missing config.php. Please make sure the OpenBroadcaster has a valid configuration file.' . PHP_EOL);
2020
}
2121

22-
if (!is_dir(__DIR__ . '/../../vendor')) {
22+
if (!is_dir(__DIR__ . '/../vendor')) {
2323
die('Missing vendor directory in OpenBroadcaster root directory. Install composer then run "composer install" to get required dependencies.' . PHP_EOL);
2424
}
2525

26-
require_once(__DIR__ . '/../../vendor/autoload.php');
26+
require_once(__DIR__ . '/../vendor/autoload.php');
2727

2828
$command = $argv[1] ?? '';
2929
$subcommand = $argv[2] ?? '';
@@ -69,9 +69,9 @@ public function check()
6969
{
7070
global $subcommand;
7171
if ($subcommand === 'install') {
72-
require(__DIR__ . '/commands/check_install.php');
72+
require(__DIR__ . '/../core/cli/check_install.php');
7373
} elseif ($subcommand === 'media') {
74-
require(__DIR__ . '/commands/check_media.php');
74+
require(__DIR__ . '/../core/cli/check_media.php');
7575
} else {
7676
$this->help();
7777
}
@@ -81,7 +81,7 @@ public function cron()
8181
{
8282
global $subcommand;
8383
if ($subcommand == 'run' || $subcommand == 'monitor') {
84-
require(__DIR__ . '/commands/cron.php');
84+
require(__DIR__ . '/../core/cli/cron.php');
8585
} else {
8686
$this->help();
8787
}
@@ -91,7 +91,7 @@ public function modules()
9191
{
9292
global $subcommand;
9393
if (in_array($subcommand, ['list', 'install', 'uninstall', 'purge'])) {
94-
require(__DIR__ . '/commands/modules.php');
94+
require(__DIR__ . '/../core/cli/modules.php');
9595
} else {
9696
$this->help();
9797
}
@@ -119,9 +119,9 @@ public function updates()
119119
}
120120

121121
if ($argv[2] == 'run') {
122-
require(__DIR__ . '/commands/updates_run.php');
122+
require(__DIR__ . '/../core/cli/updates_run.php');
123123
} elseif ($argv[2] == 'list') {
124-
require(__DIR__ . '/commands/updates_list.php');
124+
require(__DIR__ . '/../core/cli/updates_list.php');
125125
} else {
126126
$this->help();
127127
}
@@ -131,7 +131,7 @@ public function passwd()
131131
{
132132
global $subcommand;
133133
if ($subcommand) {
134-
require(__DIR__ . '/commands/passwd.php');
134+
require(__DIR__ . '/../core/cli/passwd.php');
135135
} else {
136136
$this->help();
137137
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
if (!defined('OB_CLI')) {
66
die('Command line access only.');
77
}
88

9-
require_once(__DIR__ . '/../../../public/updates/checker.php');
9+
require_once(__DIR__ . '/../../public/updates/checker.php');
1010

1111
$checker = new \OBFChecker();
1212
$methods = get_class_methods($checker);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
if (! defined('OB_CLI')) {
66
die('Command line access only.');
77
}
88

9-
require_once(__DIR__ . '/../../../core/init.php');
9+
require_once(__DIR__ . '/../init.php');
1010

1111
$db = \OBFDB::get_instance();
1212

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
define('OB_CRON_LOG', '/tmp/cronlog');
66

@@ -10,7 +10,7 @@
1010
die('Command line access only.');
1111
}
1212

13-
require_once(__DIR__ . '/../../../core/init.php');
13+
require_once(__DIR__ . '/../init.php');
1414

1515
$db = \OBFDB::get_instance();
1616

@@ -129,7 +129,7 @@
129129
if ($subcommand === 'run') {
130130
foreach ($jobs as $job) {
131131
echo "Running job '{$job['module']}/{$job['name']}'..." . PHP_EOL;
132-
exec(OB_LOCAL . '/tools/cli/ob' . ' cron run ' . $job['module'] . ' ' . $job['name'] . ' >> ' . OB_CRON_LOG . ' &');
132+
exec(OB_LOCAL . '/cli/ob' . ' cron run ' . $job['module'] . ' ' . $job['name'] . ' >> ' . OB_CRON_LOG . ' &');
133133
}
134134
} elseif ($subcommand === 'monitor') {
135135
while (true) {
@@ -143,7 +143,7 @@
143143

144144
// disabled "running" message since we have things running every second (would be good to have a debug mode)
145145
// echo "Running job '{$job['module']}/{$job['name']}'..." . PHP_EOL;
146-
exec(OB_LOCAL . '/tools/cli/ob' . ' cron run ' . $job['module'] . ' ' . $job['name'] . ' >> ' . OB_CRON_LOG . ' &');
146+
exec(OB_LOCAL . '/cli/ob' . ' cron run ' . $job['module'] . ' ' . $job['name'] . ' >> ' . OB_CRON_LOG . ' &');
147147
}
148148

149149
sleep(1);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
global $argv;
66

77
if (!defined('OB_CLI')) {
88
die('Command line access only.');
99
}
1010

11-
require_once(__DIR__ . '/../../../core/init.php');
11+
require_once(__DIR__ . '/../init.php');
1212

1313
$db = \OBFDB::get_instance();
1414
$models = \OBFModels::get_instance();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
if (!defined('OB_CLI')) {
66
die('Command line access only.');
@@ -11,7 +11,7 @@
1111

1212
$username = $subcommand;
1313

14-
require_once(__DIR__ . '/../../../core/init.php');
14+
require_once(__DIR__ . '/../init.php');
1515

1616
$db = new \OBFDB();
1717

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace ob\tools\cli;
3+
namespace OpenBroadcaster\CLI;
44

55
if (!defined('OB_CLI')) {
66
die('Command line access only.');
@@ -28,7 +28,7 @@
2828

2929
function listUpdates($type = 'core', $module = null)
3030
{
31-
require_once(__DIR__ . '/../../../public/updates/updates.php');
31+
require_once(__DIR__ . '/../../public/updates/updates.php');
3232

3333
if ($type === 'core') {
3434
// List all core updates.
@@ -40,7 +40,7 @@ function listUpdates($type = 'core', $module = null)
4040
$db = new \OBFDB();
4141

4242
// List all module updates.
43-
$modules = array_filter(scandir('./modules/'), fn($f) => $f[0] !== '.');
43+
$modules = array_filter(scandir(__DIR__ . '/../../modules/'), fn($f) => $f[0] !== '.');
4444
foreach ($modules as $module) {
4545
$db->where('directory', $module);
4646
$installed = $db->get_one('modules');

0 commit comments

Comments
 (0)