Re-implemented CLI to provide help messages.
This commit is contained in:
@@ -1,38 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* cliWorkspaces.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2011 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
* @author Alexandre Rosenfeld <alexandre@colosa.com>
|
||||
* @package workflow-engine-bin-tasks
|
||||
**/
|
||||
|
||||
pake_task('info');
|
||||
CLI::taskName('info');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Print information about the current system and specified workspaces.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace-name', true, true);
|
||||
CLI::taskRun(run_info);
|
||||
|
||||
pake_task('workspace-upgrade');
|
||||
CLI::taskName('workspace-backup');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Backup the specified workspace to an archive.
|
||||
|
||||
pake_task('workspace-backup');
|
||||
pake_task('workspace-restore');
|
||||
BACKUP-NAME is the backup filename. If it contains slashes, it will be
|
||||
treated as a filename, either absolute or relative. Otherwise it will be
|
||||
treated as a filename inside the backups directory in the 'shared' folder.
|
||||
If no BACKUP-NAME is specified, it will use the workspace name as the
|
||||
filename.
|
||||
|
||||
pake_task('translation-upgrade');
|
||||
pake_task('cacheview-upgrade');
|
||||
A backup archive will contain all information about the specified workspace
|
||||
so that it can be restored later. A database dump will be created and all
|
||||
the workspace files will be included in the archive.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace', false);
|
||||
CLI::taskArg('backup-file', true);
|
||||
CLI::taskRun(run_workspace_backup);
|
||||
|
||||
pake_task('database-upgrade');
|
||||
pake_task('database-check');
|
||||
CLI::taskName('workspace-restore');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Restore a workspace from a backup.
|
||||
|
||||
pake_task('plugins-database-upgrade');
|
||||
BACKUP-NAME is the backup filename. If it contains slashes, it will be
|
||||
treated as a filename, either absolute or relative. Otherwise it will be
|
||||
treated as a filename inside the backups directory in the 'shared' folder.
|
||||
|
||||
pake_task('database-export');
|
||||
pake_task('database-import');
|
||||
If WORKSPACE is specified, it will be used as the workspace to restore to,
|
||||
otherwise the workspace will be restored using the same name as before.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('backup-file', false);
|
||||
CLI::taskArg('workspace', true);
|
||||
CLI::taskRun(run_workspace_restore);
|
||||
|
||||
pake_task('drafts-clean');
|
||||
CLI::taskName('cacheview-repair');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Create and populate APP_CACHE_VIEW
|
||||
|
||||
function run_info($command, $args) {
|
||||
You can specify as many workspaces as you want and if no workspace is
|
||||
specified, it will run the upgrade on all available workspaces.
|
||||
|
||||
In order to improve the performance, ProcessMaker includes a cache of cases
|
||||
in the table APP_CACHE_VIEW. This table must be in sync with the database
|
||||
to present the right information in the inbox. This command will create the
|
||||
table and populate it with the right information. You only need to use this
|
||||
command after upgrading or if the inbox is out of sync.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace', true, true);
|
||||
CLI::taskRun(run_cacheview_upgrade);
|
||||
|
||||
CLI::taskName('database-upgrade');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Repair the database schema to the latest version
|
||||
|
||||
You can specify as many workspaces as you want and if no workspace is
|
||||
specified, it will run the upgrade on all available workspaces.
|
||||
|
||||
This command will read the system schema and attempt to modify the workspaces
|
||||
tables to this new schema. This is useful after an upgrade when the workspace
|
||||
database is not upgraded or when the database does not contain the right
|
||||
schema.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace', true, true);
|
||||
CLI::taskRun(run_database_upgrade);
|
||||
|
||||
CLI::taskName('plugins-database-upgrade');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Repair the database schema to the latest version
|
||||
|
||||
You can specify as many workspaces as you want and if no workspace is
|
||||
specified, it will run the upgrade on all available workspaces.
|
||||
|
||||
The same as database-upgrade but works with schemas provided by plugins.
|
||||
This is useful if there are installed plugins that include database schemas.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace', true, true);
|
||||
CLI::taskRun(run_plugins_database_upgrade);
|
||||
|
||||
CLI::taskName('workspace-upgrade');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Upgrade the workspace(s) specified.
|
||||
|
||||
If no workspace is specified, the command will be run in all workspaces. You
|
||||
can specify more then one workspace.
|
||||
|
||||
This command is a shortcut to execute all upgrade commands in this workspace.
|
||||
Upgrading a workspace will make it corresponds to this version of
|
||||
ProcessMaker. Use this command to upgrade workspaces individually, otherwise
|
||||
use the upgrade command to upgrade the entire system.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace-name', true, true);
|
||||
CLI::taskRun(run_workspace_upgrade);
|
||||
|
||||
CLI::taskName('translation-repair');
|
||||
CLI::taskDescription(<<<EOT
|
||||
Upgrade translations for the specified workspace(s).
|
||||
|
||||
If no workspace is specified, the command will be run in all workspaces. You
|
||||
can specify more then one workspace.
|
||||
|
||||
This command will go through each language installed in ProcessMaker and
|
||||
update this workspace translations to match the installed translations.
|
||||
EOT
|
||||
);
|
||||
CLI::taskArg('workspace-name', true, true);
|
||||
CLI::taskRun(run_translation_upgrade);
|
||||
|
||||
function run_info($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args, false);
|
||||
System::printSysInfo();
|
||||
workspaceTools::printSysInfo();
|
||||
foreach ($workspaces as $workspace) {
|
||||
echo "\n";
|
||||
$workspace->printMetadata(false);
|
||||
}
|
||||
}
|
||||
|
||||
function run_workspace_upgrade($command, $args) {
|
||||
function run_workspace_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
@@ -43,7 +165,7 @@ function run_workspace_upgrade($command, $args) {
|
||||
}
|
||||
}
|
||||
|
||||
function run_translation_upgrade($command, $args) {
|
||||
function run_translation_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
$updateXml = true;
|
||||
foreach ($workspaces as $workspace) {
|
||||
@@ -57,7 +179,7 @@ function run_translation_upgrade($command, $args) {
|
||||
}
|
||||
}
|
||||
|
||||
function run_cacheview_upgrade($command, $args) {
|
||||
function run_cacheview_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
$updateXml = true;
|
||||
foreach ($workspaces as $workspace) {
|
||||
@@ -70,34 +192,34 @@ function run_cacheview_upgrade($command, $args) {
|
||||
}
|
||||
}
|
||||
|
||||
function run_plugins_database_upgrade($command, $args) {
|
||||
function run_plugins_database_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
logging("Upgrading plugins database for " . info($workspace->name) . "\n");
|
||||
CLI::logging("Upgrading plugins database for " . info($workspace->name) . "\n");
|
||||
$workspace->upgradePluginsDatabase();
|
||||
} catch (Exception $e) {
|
||||
logging("Errors upgrading plugins database: " . error($e->getMessage()));
|
||||
CLI::logging("Errors upgrading plugins database: " . error($e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run_database_export($command, $args) {
|
||||
function run_database_export($args, $opts) {
|
||||
if (count($args) < 2)
|
||||
throw new Exception ("Please provide a workspace name and a directory for export");
|
||||
$workspace = new workspaceTools($args[0]);
|
||||
$workspace->exportDatabase($args[1]);
|
||||
}
|
||||
|
||||
function run_database_import($command, $args) {
|
||||
function run_database_import($args, $opts) {
|
||||
throw new Exception("Not implemented");
|
||||
}
|
||||
|
||||
function run_database_upgrade($task, $args) {
|
||||
function run_database_upgrade($args, $opts) {
|
||||
database_upgrade("upgrade", $args);
|
||||
}
|
||||
|
||||
function run_database_check($task, $args) {
|
||||
function run_database_check($args, $opts) {
|
||||
database_upgrade("check", $args);
|
||||
}
|
||||
|
||||
@@ -136,7 +258,7 @@ function delete_app_from_table($con, $tableName, $appUid, $col="APP_UID") {
|
||||
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
|
||||
}
|
||||
|
||||
function run_drafts_clean($task, $args) {
|
||||
function run_drafts_clean($args, $opts) {
|
||||
echo "Cleaning drafts\n";
|
||||
|
||||
if (count($args) < 1)
|
||||
@@ -215,16 +337,25 @@ function run_drafts_clean($task, $args) {
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
function run_workspace_backup($task, $args) {
|
||||
$workspace = new workspaceTools($args[0]);
|
||||
if (isset($args[1]))
|
||||
$filename = $args[1];
|
||||
else
|
||||
$filename = PATH_DATA . "backups/" . $workspace->name . ".tar";
|
||||
$workspace->backup($filename);
|
||||
function run_workspace_backup($args, $opts) {
|
||||
$workspaces = array();
|
||||
if (sizeof($args) > 2) {
|
||||
$filename = array_pop($args);
|
||||
foreach ($args as $arg) {
|
||||
$workspaces[] = new workspaceTools($arg);
|
||||
}
|
||||
} else if (sizeof($args) > 0) {
|
||||
$workspaces[] = new workspaceTools($args[0]);
|
||||
if (sizeof($args) == 2)
|
||||
$filename = $args[1];
|
||||
else
|
||||
$filename = $workspace->name . ".tar.gz";
|
||||
}
|
||||
foreach ($workspaces as $workspace)
|
||||
$workspace->backup($filename);
|
||||
}
|
||||
|
||||
function run_workspace_restore($task, $args) {
|
||||
function run_workspace_restore($args, $opts) {
|
||||
//$workspace = new workspaceTools($args[0]);
|
||||
workspaceTools::restore($args[0], $args[1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user