-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli
executable file
·69 lines (57 loc) · 1.43 KB
/
cli
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /usr/bin/php
<?php
require('lib/system.config.php');
require('lib/system.functions.php');
require('lib/cli.functions.php');
require('lib/plugins.functions.php');
# add standard actions here
if(($argv[1] == 'install' || $argv[1] == 'uninstall') && isset($argv[2]))
{
$action = $argv[1];
$plugin = $argv[2];
}
else
{
$plugin = $argv[1];
$action = $argv[2];
}
# require the plugin config and functions.
$config = DIR_PLUGINS.$plugin.'/lib/config.php';
$functions = DIR_PLUGINS.$plugin.'/lib/functions.php';
if(file_exists($config))
{
require($config);
}
if(file_exists($functions))
{
require($functions);
}
# define errors here.
# this is a little messy, but it's only temporary.
$errors = array(
'installed' => $_plugin['name'].' is already installed',
'not_installed' => $_plugin['name'].' is not installed',
'create_dir' => 'error creating '.$_plugin['dir']['definitions'],
'delete_dir' => 'error deleting '.$_plugin['dir']['definitions'],
'example' => 'error copying example file/s',
'installing' => 'error installing '.$_plugin['name'],
'uninstalling' => 'error uninstalling '.$_plugin['name'],
'aborted' => 'aborted...',
);
# require the plugin ops file.
require_once('plugins/'.$plugin.'/ops.php');
# if action = uninstall, add prompt (are you sure?)
# call the action and pass $argv.
call_user_func($action, $argv);
if(!$error)
{
if($success)
{
success($success);
}
}
else
{
error($error);
}
echo "\n";