Skip to content

Commit bec47ec

Browse files
committed
module cli commands skeleton
1 parent dce884b commit bec47ec

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

tools/cli/commands/module.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace ob\tools\cli;
4+
5+
global $argv;
6+
7+
if (!defined('OB_CLI')) {
8+
die('Command line access only.');
9+
}
10+
11+
require_once('components.php');
12+
13+
$db = \OBFDB::get_instance();
14+
15+
switch ($argv[2]) {
16+
case 'list':
17+
// Get all module directories and some metadata.
18+
// TODO
19+
20+
// Get all installed modules to compare against what's available.
21+
$modules = $db->get('modules');
22+
$installed = [];
23+
foreach ($modules as $module) {
24+
$installed[] = [
25+
$module['id'],
26+
$module['directory']
27+
];
28+
}
29+
30+
// List all modules and their status.
31+
$rows = $installed; // TODO
32+
echo Helpers::table(spacing: 5, rows: $rows);
33+
break;
34+
case 'install':
35+
// TODO
36+
break;
37+
case 'uninstall':
38+
// TODO
39+
break;
40+
case 'purge':
41+
// TODO
42+
// TODO: Remember to run uninstall first as well.
43+
break;
44+
}

tools/cli/ob.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function help()
6767
['cron run', 'run scheduled tasks once'],
6868
['cron run <module> <task> [now]', 'run scheduled task for module'],
6969
['cron monitor', 'monitor and run cron tasks as needed'],
70+
['module list', 'list all modules and their status'],
71+
['module install <name>', 'install module'],
72+
['module uninstall <name>', 'uninstall module'],
73+
['module purge <name>', 'uninstall module and delete all data'],
7074
['updates list all', 'list all available updates'],
7175
['updates list core', 'list core ob updates'],
7276
['updates list module <name>', 'list updates for specified module'],
@@ -92,6 +96,16 @@ public function cron()
9296
}
9397
}
9498

99+
public function module()
100+
{
101+
global $subcommand;
102+
if (in_array($subcommand, ['list', 'install', 'uninstall', 'purge'])) {
103+
require(__DIR__ . '/commands/module.php');
104+
} else {
105+
$this->help();
106+
}
107+
}
108+
95109
public function updates()
96110
{
97111
global $argv;

0 commit comments

Comments
 (0)